def zip_app(): """Remove the old zip archive and create the new one for APP_DIR.""" if not compile_app_directory(): sys.exit(0) print "Removing old zip archive..." print try: os.remove(app_zip_file()) except OSError: pass print "Creating new zip archive at:" print app_zip_file() zf = zipfile.PyZipFile(app_zip_file(), mode='w') print '******', project_dir() os.chdir(project_dir()) try: zf.writepy(app_dir(), 'app') root_len = len(project_dir()) for root, dirs, files in os.walk(app_dir()): dir_path_from_root = root[root_len:] for f in files: if not (f.endswith('.py') or f.endswith('.pyc')): fullpath = os.path.join(root, f) archive_name = os.path.join(dir_path_from_root, f) zf.write(fullpath, archive_name) finally: zf.close() print "Done."
def copy_files(): """ Bytecompile all python source files, copy them together with the .qml files to the android device. """ if not script_utils.compile_app_directory(): sys.exit(0) # Remove previous temporary deployment files from sdcard if they are any rm_cmd = [adb_path(), "shell", "rm", "-r", device_sdcard_dir()] subprocess.call(rm_cmd) root_len = len(os.path.abspath(app_dir())) for root, dirs, files in os.walk(app_dir()): archive_root = os.path.abspath(root)[root_len + 1:] for d in dirs: dest_dir = os.path.join(device_app_dir(), archive_root, d) print "Making directory:", dest_dir mkdir_cmd = [adb_path(), "shell", "su -c 'mkdir -p %s'" % dest_dir] subprocess.call(mkdir_cmd) for fn in files: if not fn.endswith('.py'): src_path = os.path.join(root, fn) dest_path = os.path.join(device_app_dir(), archive_root, fn) sd_card_fn = os.path.join(device_sdcard_dir(), archive_root, fn) # Copy the files temporarily to the sdcard push_cmd = [adb_path(), "push", src_path, sd_card_fn] subprocess.call(push_cmd) print "Copying:", src_path # Copy them from sdcard to the device_app_dir cat_cmd = [ adb_path(), "shell", "su -c 'cat %s > %s'" % (sd_card_fn, dest_path) ] subprocess.call(cat_cmd) # Remove temporary deployment files from the sdcard rm_cmd = [adb_path(), "shell", "rm", "-r", device_sdcard_dir()] subprocess.call(rm_cmd)
def copy_files(): """ Bytecompile all python source files, copy them together with the .qml files to the android device. """ if not script_utils.compile_app_directory(): sys.exit(0) # Remove previous temporary deployment files from sdcard if they are any rm_cmd = [adb_path(), "shell", "rm", "-r", device_sdcard_dir()] subprocess.call(rm_cmd) root_len = len(os.path.abspath(app_dir())) for root, dirs, files in os.walk(app_dir()): archive_root = os.path.abspath(root)[root_len + 1:] for d in dirs: dest_dir = os.path.join(device_app_dir(), archive_root, d) print "Making directory:", dest_dir mkdir_cmd = [adb_path(), "shell", "su -c 'mkdir -p %s'" % dest_dir] subprocess.call(mkdir_cmd) for fn in files: if not fn.endswith('.py'): src_path = os.path.join(root, fn) dest_path = os.path.join(device_app_dir(), archive_root, fn) sd_card_fn = os.path.join(device_sdcard_dir(), archive_root, fn) # Copy the files temporarily to the sdcard push_cmd = [adb_path(), "push", src_path, sd_card_fn] subprocess.call(push_cmd) print "Copying:", src_path # Copy them from sdcard to the device_app_dir cat_cmd = [adb_path(), "shell", "su -c 'cat %s > %s'" % (sd_card_fn, dest_path)] subprocess.call(cat_cmd) # Remove temporary deployment files from the sdcard rm_cmd = [adb_path(), "shell", "rm", "-r", device_sdcard_dir()] subprocess.call(rm_cmd)