DAT file compilation

J

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?
 
D

Diez B. Roggisch

Jay said:
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
 
J

Jay

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

James Stroud

Jay said:
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/
 
J

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.
 
M

MonkeeSage

Jay said:
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
 
N

Nick Vatamaniuc

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
 
J

James Stroud

Jay said:
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/
 
S

Steve Holden

Jay said:
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
 
R

Roger Upole

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
 
R

Roger Upole

Steve Holden said:
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
 
S

Steve Holden

Roger said:
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
 
N

Nick Craig-Wood

Jay said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top