Kivy A to Z-a simple tool for syncing Android files via ADB

Source: Internet
Author: User

To interest when writing some kivy code, debugging but always feel not very convenient. Direct packaging to the Public.mp3 way too much lock, file sharing software and found that there is no easy to use,

With Samba filesharing is also only slow, but the updated version has been prompted to say that WiFi does not tethering, meaning that WiFi hotspot is not open, but open or prompt no tethering.

I got a file manager called Zhuo Li, downloaded the samba plugin and entered the user name and password anyway, was really annoyed, took a little time to write a sync Android files through the ADB tool, with very cool.


Why do events always have to be so complicated? How good is simple? Stupid human beings.


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_inf             O[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 EXC Eption,e:print e file_info = {} compile_source () Sync_source ()


Put sync.py into the root directory of the code, execution, will automatically synchronize the PC-side modified files to Android, similar output as follows:


./sync.py

Compile. \main.py


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

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


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.