diff --git a/gist.py b/gist.py index a9fd012..aa23823 100644 --- a/gist.py +++ b/gist.py @@ -28,15 +28,17 @@ def main(wf): # Get last update last_update = wf.stored_data('last_update') - diff = (datetime.now() - last_update).seconds + if last_update: + diff = (datetime.now() - last_update).seconds - # Update daily - if diff > 60*60*24: - if not is_running(u"update_gists"): - run_in_background('update_gists',['/usr/bin/python', wf.workflowfile('update_gists.py')]) - wf.add_item('Gist Update Triggered', icon="icons/download.png") + # Update daily + if diff > 60*60*24: + if not is_running(u"update_gists"): + run_in_background('update_gists',['/usr/bin/python', wf.workflowfile('update_gists.py')]) + wf.add_item('Gist Update Triggered', icon="icons/download.png") - if is_running(u"update_gists"): + # Initial Load + if wf.stored_data('gists') is None: n = wf.stored_data('current_gist') total = wf.stored_data('total_gists') if n: @@ -44,16 +46,21 @@ def main(wf): else: status = "Gists are being updated" wf.add_item(status, icon="icons/download.png") - - - # Initial Load - if wf.stored_data('gists') is None: - wf.add_item(status, icon="icons/download.png") wf.send_feedback() if not is_running(u"update_gists"): run_in_background(u"update_gists",['/usr/bin/python', wf.workflowfile('update_gists.py')]) # Exit for initial - sys.exit() + sys.exit() + + elif is_running(u"update_gists"): + n = wf.stored_data('current_gist') + total = wf.stored_data('total_gists') + if n: + status = 'Gists are being updated ({}/{}; {}%)'.format(n, total, int((n*1.0/total)*100)) + else: + status = "Gists are being updated" + wf.add_item(status, icon="icons/download.png") + gists = wf.stored_data('gists') diff --git a/icons/Perl.png b/icons/Perl.png deleted file mode 100644 index 2399040..0000000 Binary files a/icons/Perl.png and /dev/null differ diff --git a/info.plist b/info.plist index 9d26b00..f2198f1 100644 --- a/info.plist +++ b/info.plist @@ -638,7 +638,7 @@ escaping 102 keyword - gg_set_token + gg_set queuedelaycustom 3 queuedelayimmediatelyinitially @@ -658,7 +658,7 @@ subtext title - gg_set_token <token> + gg_set <token> type 0 withspace diff --git a/update_gists.py b/update_gists.py index bb8f55a..d6739f2 100644 --- a/update_gists.py +++ b/update_gists.py @@ -18,7 +18,7 @@ def main(wf): gh = Github(login_or_token=token) gh_user = gh.get_user() gist_set = [] - user_gists = list(gh_user.get_gists())[0:20] + user_gists = list(gh_user.get_gists()) for n, gist in enumerate(user_gists): log.info(gist) gist_item = {}