Pythonを使用してbz2ファイルをダウンロードします。そして、私が使用してアーカイブを解凍します:Pythonでエラーが発生したときにUntarアーカイブ
def unpack_file(dir, file):
cwd = os.getcwd()
os.chdir(dir)
print "Unpacking file %s" % file
cmd = "tar -jxf %s" % file
print cmd
os.system(cmd)
os.chdir(cwd)
残念ながら、これはエラーで終了します。
bzip2: Compressed file ends unexpectedly;
perhaps it is corrupted? *Possible* reason follows.
bzip2: Inappropriate ioctl for device
Input file = (stdin), output file = (stdout)
It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.
You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.
tar: Nieoczekiwany EOF w archiwum
tar: Nieoczekiwany EOF w archiwum
tar: Error is not recoverable: exiting now
私は何の問題もなくシェルからアーカイブを解凍することができますが。
私が間違っていることはありますか?
はあなたがOS 'に渡すことを私たちにあなたがシェルで実行正確なコマンド、および(ファイル名を含む)正確なコマンドを示すことができましたシステム() '? – NPE
'os.system'の代わりに[' subprocess.Popen'](http://docs.python.org/library/subprocess.html#replacing-os-system)を使用してください。 – jcollado
どうやってファイルをダウンロードしていますか? unpackを呼び出す前にsleep(15)を入れても、それでも同じエラーが出ますか? – Foon