#!/usr/bin/env python3 """ ===================================================================== Post to-phone-propagation steps => EDIT ME (optionally). This script is run automatically by an import at the end of the initial-copy and sync-changes phone scripts. Hence, any code you add here will be run after all to-phone content propagations. Example: if you are storing content in Termux's app-specific storage for its speed, you may wish to copy select content to shared storage (/sdcard) so it can be accessed from other apps. This can be used only to copy to shared storage; Termux cannot access other apps' storage in Android 11 (and vice versa). See _README.html for license, attribution, version, and docs. ===================================================================== """ print('\nRunning postcopy hooks') import os, sys, shutil from os.path import join from config_phone import * # get phone-specific settings # Or, if you need utilities in common.py: """ import config_phone, common # get phone settings and common code common.startup(config_phone, common) # copy and use phone config's settings from common import * # use both's top-level names as globals """ #------------------------------------------------------------------ # Example: copy calendar ICS files to shared storage for use by # the Frigcal tkinter GUI run in the Pydroid 3 app. Py apps do # not normally have access to other apps' app-specific storage. # Or: run Frigcal in shared Download/ and keep calendars there. # # print('\nCopying calendar content to shared storage') # arch = '%s/%s/Code/frigcal/Calendars' % (TO, STUFF) # live = '/sdcard/Downloads/Frigcal-source/Calendars' # if os.path.exists(live): # shutil.rmtree(live) # shutil.copytree(arch, live) # copies metadata too #------------------------------------------------------------------ #------------------------------------------------------------------ # Example: sync music up for use by Folder Player; or share with # a shuffling player, or open in CX file explorer's player, or... # # print('\nSyncing MP3s to shared storage') # shared = '/sdcard/Music/Jazz' # if not os.path.exists(shared): # os.mkdir(shared) # os.system('python3 %s/mergeall.py ' # '%s/%s/Music/Jazz %s -auto -skipcruft -quiet' # % (MALL, TO, STUFF, shared)) #------------------------------------------------------------------ #------------------------------------------------------------------ # But this doesn't work: Termux cannot access other apps' storage, # so this requires a manual file-explorer copy (or Android 10). # Update: some explorers spawn HTTP servers or use content URIs # on Android 11 that work as well as this for local-file views. # # browser = 'sdcard/Android/data/com.android.chrome/UNION' # if os.path.exists(browser): # shutil.rmtree(browser) # shutil.copytree('%s/%s/Websites/UNION' % (TO, STUFF), browser) #------------------------------------------------------------------