From 314272f582123318eb5cf190d9e155b229f66200 Mon Sep 17 00:00:00 2001 From: matlink Date: Fri, 28 Aug 2015 22:52:27 +0200 Subject: [PATCH] [upd] adding cronjob creation for daily or weekly updates --- MANIFEST.in | 1 + README.md | 3 +++ cron/.cronjob.swp | Bin 0 -> 12288 bytes cron/cronjob | 4 ++++ gplaycli | 33 +++++++++++++++++++++++++++++++++ setup.py | 4 ++-- 6 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 cron/.cronjob.swp create mode 100755 cron/cronjob diff --git a/MANIFEST.in b/MANIFEST.in index 25e2b66..ed87ace 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,2 @@ include credentials.conf +include cron/cronjob diff --git a/README.md b/README.md index 19aa81e..f77b703 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,9 @@ GPlayCli is a command line tool to search, install, update Android applications -c CONF_FILE, --config CONF_FILE Use a different config file than credentials.conf -p, --progress Prompt a progress bar while downloading packages + -ic, --install-cronjob + Interactively install cronjob for regular APKs update + Keep in mind that GPlayCli is not able to download apps that are not gratis, costless. diff --git a/cron/.cronjob.swp b/cron/.cronjob.swp new file mode 100644 index 0000000000000000000000000000000000000000..cf14facff8a0b61bfbe0dd54dc277bce8f268162 GIT binary patch literal 12288 zcmeI&O-{l<7=Yog#)TWB(F@e-QYN(cF+oGRC3z>APQIU+WS(8qwu)EPGxK1lBxes(ttg(x0$dw*in+N%7UY`Bhl?pMp+rKL8f!*-Z-RP%AobKFMY*Mer< XDf_M^GMzfAdx6eL<@XGo)1iC=`Sej3 literal 0 HcmV?d00001 diff --git a/cron/cronjob b/cron/cronjob new file mode 100755 index 0000000..b256a39 --- /dev/null +++ b/cron/cronjob @@ -0,0 +1,4 @@ +CREDENTIALS=PL_CRED +FOLDER_TO_UPDATE=PL_FOLD + +gplaycli --config "$CREDENTIALS" --update "$FOLDER_TO_UPDATE" diff --git a/gplaycli b/gplaycli index 1e08e42..e4ed2de 100755 --- a/gplaycli +++ b/gplaycli @@ -260,6 +260,36 @@ class GPlaycli(object): self.download_selection(self.playstore_api, [(pkg,None) for pkg in list_of_packages_to_download], self.after_download) +def install_cronjob(): + import shutil, stat + cred_default = '/etc/gplaycli/credentials.conf' + credentials = raw_input('path to credentials.conf? let empty for '+cred_default+'\n') or cred_default + fold_default = '/opt/apks' + folder_to_update = raw_input('path to apks folder? let empty for '+fold_default+'\n') or fold_default + frequence = raw_input('update it [d]aily or [w]eekly?\n') + if frequence == 'd': + frequence_folder = '/etc/cron.daily' + elif frequence == 'w': + frequence_folder = '/etc/cron.weekly' + else: + raise Exception('please type h/d/w to make your choice') + return 1 + frequence_file = frequence_folder+'/gplaycli' + shutil.copyfile('/etc/gplaycli/cronjob', frequence_file) + fi = open('/etc/gplaycli/cronjob', 'r') + fo = open(frequence_file, 'w') + for line in fi: + line = line.replace('PL_FOLD', folder_to_update) + line = line.replace('PL_CRED', credentials) + fo.write(line) + fi.close() + fo.close() + st = os.stat(frequence_file) + os.chmod(frequence_file, st.st_mode | stat.S_IEXEC) + print('Cronjob installed at '+frequence_file) + return 0 + + def main(): parser = argparse.ArgumentParser(description="A Google Play Store Apk downloader and manager for command line") parser.add_argument('-y','--yes', action='store_true',dest='yes_to_all',help='Say yes to all prompted questions') @@ -279,9 +309,12 @@ def main(): parser.add_argument('-c','--config',action='store',dest='config',metavar="CONF_FILE",nargs=1, type=str,default="credentials.conf",help="Use a different config file than credentials.conf") parser.add_argument('-p','--progress', action='store_true',dest='progress_bar',help='Prompt a progress bar while downloading packages') + parser.add_argument('-ic','--install-cronjob', action='store_true',dest='install_cronjob',help='Interactively install cronjob for regular APKs update') if len(sys.argv)<2: sys.argv.append("-h") args = parser.parse_args() + if args.install_cronjob: + sys.exit(install_cronjob()) cli = GPlaycli(args.config) cli.yes = args.yes_to_all cli.verbose = args.verbose diff --git a/setup.py b/setup.py index 0aae679..fb334a3 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ import os setup(name='GPlayCli', - version='0.1', + version='0.1.1', description='GPlayCli, a Google play downloader command line interface', author="Matlink", author_email="matlink@matlink.fr", @@ -18,7 +18,7 @@ 'ext_libs/', ], data_files=[ - ['/etc/gplaycli/', ['credentials.conf']], + ['/etc/gplaycli/', ['credentials.conf','cron/cronjob']], ], install_requires=[ 'requests',