Skip to content

Commit

Permalink
[upd] adding cronjob creation for daily or weekly updates
Browse files Browse the repository at this point in the history
  • Loading branch information
matlink committed Aug 28, 2015
1 parent 50d888c commit 314272f
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 2 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include credentials.conf
include cron/cronjob
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Binary file added cron/.cronjob.swp
Binary file not shown.
4 changes: 4 additions & 0 deletions cron/cronjob
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CREDENTIALS=PL_CRED
FOLDER_TO_UPDATE=PL_FOLD

gplaycli --config "$CREDENTIALS" --update "$FOLDER_TO_UPDATE"
33 changes: 33 additions & 0 deletions gplaycli
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -18,7 +18,7 @@
'ext_libs/',
],
data_files=[
['/etc/gplaycli/', ['credentials.conf']],
['/etc/gplaycli/', ['credentials.conf','cron/cronjob']],
],
install_requires=[
'requests',
Expand Down

0 comments on commit 314272f

Please sign in to comment.