By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,660 Members | 1,102 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,660 IT Pros & Developers. It's quick & easy.

DAT file compilation

P: n/a
Jay
Is there a way through python that I can take a few graphics and/or
sounds and combine them into a single .dat file? If so, how? And how
can I access the data in the .dat file from inside the python script?

Sep 29 '06 #1
Share this Question
Share on Google+
12 Replies


P: n/a
Jay schrieb:
Is there a way through python that I can take a few graphics and/or
sounds and combine them into a single .dat file? If so, how? And how
can I access the data in the .dat file from inside the python script?
Use a zip-file. See the zipfile-module.

Diez
Sep 29 '06 #2

P: n/a
Jay
That's one solution, but I'd rather a file format the end-user can't
easily mess around with.
Diez B. Roggisch wrote:
Jay schrieb:
Is there a way through python that I can take a few graphics and/or
sounds and combine them into a single .dat file? If so, how? And how
can I access the data in the .dat file from inside the python script?

Use a zip-file. See the zipfile-module.

Diez
Sep 29 '06 #3

P: n/a
Jay wrote:
That's one solution, but I'd rather a file format the end-user can't
easily mess around with.
Require the program to be installed as root and installation to be in a
read-only directory--or serve the resources to your program from a cgi
script somewhere, only to be downloaded when needed. This way, the user
would at least have to reverse engineer your program to see where the
resources were coming from so they could plug the appropriate query in
their web browser.

James
--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
Sep 30 '06 #4

P: n/a
Jay
That cgi idea is really cool, but I don't have any web space to host
the files. Plus the bandwidth required would be deadly. I think I'll
just have to stick to the zip file idea. The problem with the
read-only is that this program is aimed at a Windows audience.

James Stroud wrote:
Jay wrote:
That's one solution, but I'd rather a file format the end-user can't
easily mess around with.

Require the program to be installed as root and installation to be in a
read-only directory--or serve the resources to your program from a cgi
script somewhere, only to be downloaded when needed. This way, the user
would at least have to reverse engineer your program to see where the
resources were coming from so they could plug the appropriate query in
their web browser.

James
--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
Sep 30 '06 #5

P: n/a
Jay wrote:
Is there a way through python that I can take a few graphics and/or
sounds and combine them into a single .dat file? If so, how? And how
can I access the data in the .dat file from inside the python script?
How about in a sqlite database? Sqlite has built-in bindings in python
2.5 and is available as a third-party extension in previous versions.
It's also pretty easy to use, but makes you data harder to tamper with
by an average windows user.

http://docs.python.org/lib/module-sqlite3.html (See also the "See Also"
section ;) ).

Regards,
Jordan

Sep 30 '06 #6

P: n/a
You can always use pickle. Have a script that reads your folder with
the media, insert the images and sounds into arrays or your own special
classes then use pickle to dump them to a .dat file. The user gets just
one .dat file.

When your program runs, it reads the object with the data from the
disk, no need to translate from a special data format, instantiate
objects, fill those objects with data and so on, because your "frozen"
Python objects are good to be used as soon as they are loaded. Note:
this might speed up things a little during initialization of your
program.

Also, you can use cPickle for a much faster pickle (but check out the
constraints imposed by cPickle in the Python documentation).

Hope this helps,
-Nick Vatamaniuc

Jay wrote:
Is there a way through python that I can take a few graphics and/or
sounds and combine them into a single .dat file? If so, how? And how
can I access the data in the .dat file from inside the python script?
Sep 30 '06 #7

P: n/a
Jay wrote:
That cgi idea is really cool, but I don't have any web space to host
the files. Plus the bandwidth required would be deadly.
I think you are overestimating the cost of bandwidth. By the time it
becomes an issue, you've sold so many units of software, and people are
using your program so much, that you'll probably be able to go ahead and
buy your own hosting company. One python hosting company offers 50GB/mo
bandwidth for $7.50/mo. Google "python hosting" and you'll find them.
That's hella usage of a program.

James
--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
Sep 30 '06 #8

P: n/a
Jay wrote:
That cgi idea is really cool, but I don't have any web space to host
the files. Plus the bandwidth required would be deadly. I think I'll
just have to stick to the zip file idea. The problem with the
read-only is that this program is aimed at a Windows audience.
So don't call it something.zip. Since most Windows users rely on the
registry to discern filetypes from extensions you will probably find in
practice that very few actually poke about with your ".dat" file that's
actually a zip.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

Sep 30 '06 #9

P: n/a
On Windows NTFS file systems, you can add data to a file using named streams.
The extra streams aren't visible from Explorer so the average end-user won't
even know they're there.

Roger
"Jay" <ja*******@gmail.comwrote in message news:11**********************@m73g2000cwd.googlegr oups.com...
That cgi idea is really cool, but I don't have any web space to host
the files. Plus the bandwidth required would be deadly. I think I'll
just have to stick to the zip file idea. The problem with the
read-only is that this program is aimed at a Windows audience.

James Stroud wrote:
>Jay wrote:
That's one solution, but I'd rather a file format the end-user can't
easily mess around with.

Require the program to be installed as root and installation to be in a
read-only directory--or serve the resources to your program from a cgi
script somewhere, only to be downloaded when needed. This way, the user
would at least have to reverse engineer your program to see where the
resources were coming from so they could plug the appropriate query in
their web browser.

James
--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Sep 30 '06 #10

P: n/a
Roger Upole wrote:
On Windows NTFS file systems, you can add data to a file using named streams.
The extra streams aren't visible from Explorer so the average end-user won't
even know they're there.
I hadn't realised how easy it is to access alternate data streams from
Python. A filename of the right form ("basefile.ext:alternatename")
works just fine, it appears.

Unfortunately you then have the problem of how to create it, since there
is no way to carry it around outside an NTFS filesystem, so some sort of
post-install script would be required.

There's also the issue that alternate data stream of any significant
size will be regarded with great suspicion by forensic examinations and
similar tests.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

Sep 30 '06 #11

P: n/a

"Steve Holden" <st***@holdenweb.comwrote in message news:ma***************************************@pyt hon.org...
Roger Upole wrote:
>On Windows NTFS file systems, you can add data to a file using named streams.
The extra streams aren't visible from Explorer so the average end-user won't
even know they're there.
I hadn't realised how easy it is to access alternate data streams from Python. A filename of the right form
("basefile.ext:alternatename") works just fine, it appears.

Unfortunately you then have the problem of how to create it, since there is no way to carry it around outside an NTFS
filesystem, so some sort of post-install script would be required.

There's also the issue that alternate data stream of any significant size will be regarded with great suspicion by forensic
examinations and similar tests.

regards
Steve
--
Another drawback is that you have to be careful how you move the files
around. shutil.copyfile doesn't pick up alternate streams. Also, there's
no way from stock python to enumerate the streams. (but that could be a
plus for the OP)

Roger


----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Sep 30 '06 #12

P: n/a
Jay <ja*******@gmail.comwrote:
Diez B. Roggisch wrote:
Jay schrieb:
Is there a way through python that I can take a few graphics and/or
sounds and combine them into a single .dat file? If so, how? And how
can I access the data in the .dat file from inside the python script?
Use a zip-file. See the zipfile-module.

That's one solution, but I'd rather a file format the end-user can't
easily mess around with.
Just don't give it a .zip extension. Works for java and .jar, and
openoffice and all of its many extensions.

If you are feeling really paranoid then encrypt it.

--
Nick Craig-Wood <ni**@craig-wood.com-- http://www.craig-wood.com/nick
Oct 2 '06 #13

This discussion thread is closed

Replies have been disabled for this discussion.