开发者

Gracefully convert .rar to .zip using Python

开发者 https://www.devze.com 2022-12-12 07:45 出处:网络
I\'m currently making system call to \"unrar and zip\" commands. It interrupts and requires me to enter password while encounter password propected archives.

I'm currently making system call to "unrar and zip" commands. It interrupts and requires me to enter password while encounter password propected archives.

Is it possible to let it run and return a "unsuccessful" value to main program on any error or password prompt?

Can we natively use rarfile and zipfile library to do the job without creating any te开发者_如何学编程mporary files?


I think it's very difficult to do the task without using temporary files. If you are converting very large files you need to use temporary space in disk.

You can use the PyUnRAR2 library, it will let you examine and extract the files of a RAR archive. You can extract the files to a temporary folder created with the tempfile python module. After that create a ZIP file using the zipfile python module.

Note that in order to use PyUnRAR2 you need the RAR proprietary binary files.


Maybe this could help: http://www.noah.org/wiki/Pexpect#Description_of_Pexpect

0

精彩评论

暂无评论...
验证码 换一张
取 消