0

I want to use some data in my python script, but I don't want to ship script and data separatly. I'm trying to zip this data and attach them to the end of the script. I know script length, I can offset file handler to beginning of data set. Something like this

#! /usr/bin/env python
OFFSET=058119
....
with open(sys.argv[0],"rb") as fd:
  fd.seek(OFFSET)
  zfile = zipfile.ZipFile(fd)
  zfile.read("some_name")

....
#end of script
exit(0)
PK^C^D
^@^@^@^@^@<D1>^T<86>I^@^@^@^@^@^@^@^@^@^@^@^@^F^@^\^@icons/UT   ^@^C<FA>jFX.kFXux^K^@^A^D<E8>^C^@^@^D<E8>^C^@^@PK^C^D^T^@^@^@^H^@<CA>^K<86>I<E8><B9>k<92><B0>^@^@^@e^A^@^@^Q^@^\^@icons/pcloader.pyUT   ^@^C<FB>ZFX<9D><EB>FXux^K^@^A^D<E8>^C^@^@^D<E8>^C^@^@u<D0>M
......

I can extract and unpack zip file as well as run script separately, but not a composite file...

./X
/usr/bin/python: can't find '__main__' module in './X'

python X 
/usr/bin/python: can't find '__main__' module in 'X'

Any ideas?

rth
  • 2,946
  • 1
  • 22
  • 27

0 Answers0