Kivy a to Z -- a simple tool for synchronizing Android system files through adb

Source: Internet
Author: User

Kivy a to Z -- a simple tool for synchronizing Android system files through adb

When I was interested, I wrote some Kivy code, but debugging was not very convenient. The method of directly logging to public.mp3 is too complicated, and file sharing software finds that there is no easy-to-use method,

The use of samba filesharing is also slow, but the updated version has always prompted that no tethering is available for wifi, which means that no tethering is enabled for wifi hotspots.

I found a file manager named Zhuo * Li. After downloading the samba plug-in, I entered the username and password. It was really annoying, it took some time to write a tool for synchronizing Android files through adb, which was quite helpful.


Why are events always so complicated? How simple is it? Stupid human.


Sync. py

import osfrom os.path import join, getsizeimport pickleimport subprocessfile_info = Nonedef compile_source():    for root, dirs, files in os.walk('.'):        for f in files:            if f in ['sync.py','dump.pkl']:                continue            if not f.endswith('.py'):                continue            p = join(root,f)            size = os.path.getsize(p)            fstat = os.stat(p)            info = (size,fstat.st_mtime)            if p in file_info and  info == file_info[p]:                if os.path.exists(p.replace('.py','.pyo')):                    continue            print 'compile ',p            print subprocess.check_output('python -OO -m py_compile '+p)def sync_source():    for root, dirs, files in os.walk('.'):        for f in files:            if f in ['sync.py','sync.pyo','dump.pkl']:                continue#            if f.endswith('.py'):#                continue            p = join(root,f)            size = os.path.getsize(p)            fstat = os.stat(p)            info = (size,fstat.st_mtime)            if p in file_info and  info == file_info[p]:                    continue            file_info[p] = info            root_dir = '/mnt/sdcard/kivy/'#            root_dir = '/mnt/shell/emulated/0/org.test.kivycatalog'            cmd = ['adb','push',p,join(root_dir,p[2:].replace('\\','/'))]            print ' '.join(cmd)            print subprocess.check_output(cmd)        with open('dump.pkl','wb') as f:        pickle.dump(file_info,f)if __name__ == '__main__':    try:        with open('dump.pkl','rb') as f:            file_info = pickle.load(f)    except Exception,e:        print e        file_info = {}        compile_source()    sync_source()


Put sync. py in the root directory of the code and execute it. The modified files on the PC end are automatically synchronized to the android end. Similar output is as follows:


./Sync. py

Compile. \ main. py


Adb push. \ main. py/mnt/sdcard/kivy/main. py
406 KB/s (5839 bytes in 0.014 s)

Adb push. \ main. pyo/mnt/sdcard/kivy/main. pyo
403 KB/s (5372 bytes in 0.013 s)


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.