Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def untar(self, tar_file, destination):
- total_size = os.path.getsize(tar_file)
- class MyFileObj(file):
- def read(self, size):
- status = "Extracting: %s (%s bytes) [%3.2f%%]" % (os.path.basename(tar_file), total_size, self.tell() * 100. / total_size)
- status = status + chr(8)*(len(status)+1)
- print(status, end="")
- sys.stdout.flush()
- return file.read(self, size)
- tar = tarfile.open(fileobj=MyFileObj(tar_file))
- tar.extractall(destination)
- num_files = len(tar.getmembers())
- tar.close()
- return num_files
- Traceback (most recent call last):
- File "./manage.py", line 32, in <module>
- main()
- File "./manage.py", line 22, in main
- addon.get(args[2], args[3])
- File "/home/srcds/newservers/libmanage.py", line 83, in get
- num_files = self.untar(file_path, ADDONS+name+'/')
- File "/home/srcds/newservers/libmanage.py", line 128, in untar
- class MyFileObj(file):
- NameError: global name 'file' is not defined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement