Daniel Holbach has proposed merging lp:~dholbach/loco-directory/628155 into
lp:loco-directory.
Requested reviews:
loco-directory-dev (loco-directory-dev)
Related bugs:
#628155 let run_job() write log files
https://bugs.launchpad.net/bugs/628155
--
https://code.launchpad.net/~dholbach/loco-directory/628155/+merge/34426
Your team loco-directory-dev is requested to review the proposed merge of
lp:~dholbach/loco-directory/628155 into lp:loco-directory.
=== modified file 'loco_directory/common/utils.py'
--- loco_directory/common/utils.py 2010-08-28 19:27:47 +0000
+++ loco_directory/common/utils.py 2010-09-02 14:43:41 +0000
@@ -6,6 +6,15 @@
from django.conf import settings
+def write_log(job_name, log):
+ stamp_dir = os.path.join(settings.PROJECT_PATH, 'data')
+ log_file = os.path.join(stamp_dir, "%s.log" % job_name)
+ if os.path.exists(log_file):
+ os.remove(log_file)
+ f = open(log_file, "a")
+ f.write(log)
+ f.close()
+
def run_job(which, interval, args=None):
stamp_dir = os.path.join(settings.PROJECT_PATH, 'data')
if not os.path.exists(stamp_dir):
@@ -15,10 +24,14 @@
datetime.datetime.utcfromtimestamp(os.path.getmtime(stamp_file)) + interval < datetime.datetime.now():
pwd = os.getcwd()
os.chdir(settings.PROJECT_PATH)
- subprocess.call(["./manage.py", which])
+ p = subprocess.Popen(["./manage.py", which], stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT, close_fds=True)
+ log = p.stdout.read()
+ p.communicate()
os.chdir(pwd)
open(stamp_file, "a").close()
os.utime(stamp_file, None)
+ write_log(which, log)
def flat_list(some_list):
"""
_______________________________________________
Mailing list: https://launchpad.net/~loco-directory-dev
Post to : [email protected]
Unsubscribe : https://launchpad.net/~loco-directory-dev
More help : https://help.launchpad.net/ListHelp