Python uses 7z to extract APK packets _python

Source: Internet
Author: User

This article describes the way Python uses 7z to extract APK packets. Share to everyone for your reference. Specifically as follows:

This code is called 7z to decompress the APK package through the shell.

def run_shell (Command, Mayfreeze=false): Def check_retcode (Retcode, cmd): if 0!= retcode:print >> sys.stderr, 
 ' Err executing ' + cmd + ': ', Retcode sys.exit (retcode) def read_close (f): F.seek (0) d = f.read () f.close () return D #print >> sys.stderr, '-Executing ', command if mayfreeze:tempout, Temperr = Tempfile. Temporaryfile (), Tempfile. Temporaryfile () #open (Os.devnull, ' w ') p = subprocess. 
 Popen (Command, Stdout=tempout, Stderr=temperr) p.wait () output, errout = Read_close (tempout), Read_close (temperr) Else: P=subprocess. Popen (command,stdout=subprocess. Pipe,stderr=subprocess. PIPE) output = P.stdout.read () p.wait () Errout = P.stderr.read () p.stdout.close () p.stderr.close () #check_retcode p. ReturnCode, command) return (Output.strip (), Errout.strip ()) #z7 are the full path to 7z.exe #at times you have to encode The command into Gbk/utf8 run_shell (U ' {0}-y-o ' {1} ' {2} x ' {3} '. Format (Z7, TempDir, Icon, apk)) shutil.copy (U ' {0}/{1} '. f Ormat (TEMPDIR,OS.PAth.basename (icon)), Dst_path

 

I hope this article will help you with your Python programming.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.