From 92d7ccf331518eb858411af790782aca18d93dc0 Mon Sep 17 00:00:00 2001 From: Oleg Blokhin Date: Wed, 21 May 2014 17:28:11 +0400 Subject: [PATCH 1/4] Add support of --folder paramter for cron. Before this changes crontab from directories (except native applications) was ignored --- git | 0 gluon/newcron.py | 4 ++-- gluon/widget.py | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 git diff --git a/git b/git new file mode 100644 index 00000000..e69de29b diff --git a/gluon/newcron.py b/gluon/newcron.py index 7245507c..47891342 100644 --- a/gluon/newcron.py +++ b/gluon/newcron.py @@ -320,8 +320,8 @@ def crondance(applications_parent, ctype='soft', startup=False, apps=None): w2p_path = fileutils.abspath('web2py.py', gluon=True) if os.path.exists(w2p_path): commands.append(w2p_path) - if global_settings.applications_parent != global_settings.gluon_parent: - commands.extend(('-f', global_settings.applications_parent)) + if applications_parent != global_settings.gluon_parent: + commands.extend(('-f', applications_parent)) citems = [(k in task and not v in task[k]) for k, v in checks] task_min = task.get('min', []) if not task: diff --git a/gluon/widget.py b/gluon/widget.py index 770e3aed..cf885ae6 100644 --- a/gluon/widget.py +++ b/gluon/widget.py @@ -225,8 +225,8 @@ class web2pyDialog(object): text=str(ProgramVersion + "\n" + ProgramAuthor), font=('Helvetica', 11), justify=Tkinter.CENTER, foreground='#195866', background=bg_color, - height=3).pack( side='top', - fill='both', + height=3).pack( side='top', + fill='both', expand='yes') self.bannerarea.after(1000, self.update_canvas) @@ -246,7 +246,7 @@ class web2pyDialog(object): [('0.0.0.0', 'Public')] for ip, legend in ips: self.ips[ip] = Tkinter.Radiobutton( - self.root, bg=bg_color, highlightthickness=0, + self.root, bg=bg_color, highlightthickness=0, selectcolor='light grey', width=30, anchor=Tkinter.W, text='%s (%s)' % (legend, ip), justify=Tkinter.LEFT, @@ -1119,6 +1119,8 @@ def start(cron=True): # ## if -S start interactive shell (also no cron) if options.shell: + if options.folder: + os.chdir(options.folder) if not options.args is None: sys.argv[:] = options.args run(options.shell, plain=options.plain, bpython=options.bpython, From 89e38fb15bb6f5be81cee31edad3d9a8c45bd18d Mon Sep 17 00:00:00 2001 From: jmistx Date: Wed, 21 May 2014 17:32:03 +0400 Subject: [PATCH 2/4] Delete git unneeded file --- git | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 git diff --git a/git b/git deleted file mode 100644 index e69de29b..00000000 From 87cf9307f0c06eb9825f582b23f138cf9921a5fe Mon Sep 17 00:00:00 2001 From: Oleg Blokhin Date: Wed, 21 May 2014 18:18:19 +0400 Subject: [PATCH 3/4] fix cron hang on Ctrl+C terminating from terminal --- gluon/newcron.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gluon/newcron.py b/gluon/newcron.py index 47891342..637f8b7e 100644 --- a/gluon/newcron.py +++ b/gluon/newcron.py @@ -48,7 +48,13 @@ def stopcron(): global _cron_stopping _cron_stopping = True while _cron_subprocs: - _cron_subprocs.pop().terminate() + proc = _cron_subprocs.pop() + if proc.poll() is None: + try: + proc.terminate() + except: + import traceback + traceback.print_exc() class extcron(threading.Thread): From 53e22fc31c24fdedf4800ee2219855315d866fb8 Mon Sep 17 00:00:00 2001 From: Oleg Blokhin Date: Thu, 22 May 2014 16:46:06 +0400 Subject: [PATCH 4/4] Terminate subprocesses right way on cronstop --- gluon/newcron.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gluon/newcron.py b/gluon/newcron.py index 637f8b7e..96e1e917 100644 --- a/gluon/newcron.py +++ b/gluon/newcron.py @@ -260,7 +260,10 @@ class cronlauncher(threading.Thread): shell=self.shell) _cron_subprocs.append(proc) (stdoutdata, stderrdata) = proc.communicate() - _cron_subprocs.remove(proc) + try: + _cron_subprocs.remove(proc) + except ValueError: + pass if proc.returncode != 0: logger.warning( 'WEB2PY CRON Call returned code %s:\n%s' %