make_ext4fs -l 512M -s -a system system.img ./system
- -l partition size
- -s sparse mode 压缩模式,将image文件压缩
- -a system mount point make_ext4fs会根据private/android_filesystem_config.h里定义好的权限来给文件夹里的所有文件重新设置权限
- ./system file directory
| # http://stackoverflow.com/a/707001/668223 | |
| import os | |
| from subprocess import Popen, PIPE | |
| process = Popen(["ls", "-la", "."], stdout=PIPE) | |
| exit_code = os.waitpid(process.pid, 0) | |
| output = process.communicate()[0] | |
| # 更好的做法应该是 | |
| # http://docs.python.org/2/library/subprocess.html |
| def start_thread_wrapper(target_func,name='thread-', thread_number=1,daemon=True, args=()): | |
| assert target_func != None and hasattr(target_func, '__call__') | |
| for i in xrange(thread_number): | |
| t = threading.Thread(target=target_func,name=name+str(i), args=args) | |
| t.daemon = daemon | |
| t.start() |
| adb shell screencap -p | sed 's/\r$//' > screen.png |
| #Credit: http://stackoverflow.com/a/4642213/668223 | |
| FILE=test | |
| while read CMD; do | |
| echo "$CMD" | |
| done < "$FILE" |
| class QueueItem: | |
| def __init__(self, data): | |
| self.data = data | |
| self.next = None | |
| def __repr__(self): | |
| string = "Data: {}".format(str(self.data)) | |
| return string | |
| class LinkedQueue: | |
| def __init__(self): |
| import logging | |
| class Stack: | |
| def __init__(self): | |
| self.__space = [] | |
| self.cur = -1 | |
| def pop(self): | |
| if self.cur == -1: | |
| logging.warn("pop an empty stack") | |
| return None |
| #credit:http://www.cyberciti.biz/faq/bash-csh-sh-check-and-file-file-size/ | |
| stat -c %s $file |
make_ext4fs -l 512M -s -a system system.img ./system
| function exist() { | |
| if [ ! -z $1 ];then | |
| if ls $1 &>/dev/null;then | |
| echo 0 | |
| return 0 | |
| fi | |
| fi | |
| echo 1 | |
| return 1 | |
| } |
| #!/usr/bin/python | |
| #-*- encoding:utf-8 -*- | |
| class ClassTest: | |
| FOO = 'foo' | |
| __bar = 'secret!' | |
| def __init__(self, **args): | |
| self.__dict = {} | |
| self.__dict[ClassTest.FOO] = args[ClassTest.FOO] | |
| self.fill_dict(ClassTest.FOO, **args) |