Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tonytan4ever/f770c3a57294d9c18a954c6fa1f757b0 to your computer and use it in GitHub Desktop.
Save tonytan4ever/f770c3a57294d9c18a954c6fa1f757b0 to your computer and use it in GitHub Desktop.
In [9]: os.remove('/home/contractor/digitsjobs-dev/20160608-135552-c6b8/job_id_model_files.zip')
In [10]: with libarchive.Archive(target_file_name, 'w') as a:
....: for file_name in model_files:
....: a.writepath(libarchive.Entry(file_name), file_name)
....:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-10-3a91c598dd5f> in <module>()
----> 1 with libarchive.Archive(target_file_name, 'w') as a:
2 for file_name in model_files:
3 a.writepath(libarchive.Entry(file_name), file_name)
4
NameError: name 'libarchive' is not defined
In [11]: import libarchive
In [12]: with libarchive.Archive(target_file_name, 'w') as a:
for file_name in model_files:
a.writepath(libarchive.Entry(file_name), file_name)
....:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-12-3a91c598dd5f> in <module>()
1 with libarchive.Archive(target_file_name, 'w') as a:
2 for file_name in model_files:
----> 3 a.writepath(libarchive.Entry(file_name), file_name)
4
/home/contractor/.virtualenv/dappir/local/lib/python2.7/site-packages/libarchive/__init__.pyc in writepath(self, f, pathname)
557 self.write(member, data=f.read())
558 else:
--> 559 self.write(member)
560
561 def writestream(self, pathname, size=None):
/home/contractor/.virtualenv/dappir/local/lib/python2.7/site-packages/libarchive/__init__.pyc in write(self, member, data)
539 if data:
540 member.size = len(data)
--> 541 member.to_archive(self)
542 if data:
543 _libarchive.archive_write_data_from_str(self._a, data)
/home/contractor/.virtualenv/dappir/local/lib/python2.7/site-packages/libarchive/__init__.pyc in to_archive(self, archive)
355 try:
356 _libarchive.archive_entry_set_pathname(e, self.pathname.encode(self.encoding))
--> 357 _libarchive.archive_entry_set_filetype(e, stat.S_IFMT(self.mode))
358 _libarchive.archive_entry_set_perm(e, stat.S_IMODE(self.mode))
359 _libarchive.archive_entry_set_size(e, self.size)
/home/contractor/.virtualenv/dappir/lib/python2.7/stat.pyc in S_IFMT(mode)
23
24 def S_IFMT(mode):
---> 25 return mode & 0170000
26
27 # Constants used as S_IFMT() for various file types
TypeError: unsupported operand type(s) for &: 'NoneType' and 'int'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment