From 7798934989493a269070785283de1e22f4ba1baf Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 10 Oct 2013 12:03:11 +0530 Subject: [PATCH] [minor] fixed globals and patch for wsgi migration --- .../p06_fix_sle_against_stock_entry.py | 18 +++++------ patches/october_2013/p04_wsgi_migration.py | 30 +++++++++++++++++++ patches/patch_list.py | 1 + utilities/demo/make_demo.py | 2 +- utilities/demo/make_erpnext_demo.py | 2 +- 5 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 patches/october_2013/p04_wsgi_migration.py diff --git a/patches/august_2013/p06_fix_sle_against_stock_entry.py b/patches/august_2013/p06_fix_sle_against_stock_entry.py index 02588bec6d..2e6c383ebd 100644 --- a/patches/august_2013/p06_fix_sle_against_stock_entry.py +++ b/patches/august_2013/p06_fix_sle_against_stock_entry.py @@ -1,10 +1,9 @@ import webnotes -cancelled = [] -uncancelled = [] - def execute(): - global cancelled, uncancelled + cancelled = [] + uncancelled = [] + stock_entries = webnotes.conn.sql("""select * from `tabStock Entry` where docstatus >= 1 and date(modified) >= "2013-08-16" and ifnull(production_order, '') != '' and ifnull(bom_no, '') != '' @@ -17,14 +16,12 @@ def execute(): where voucher_type='Stock Entry' and voucher_no=%s and is_cancelled='No'""", entry.name, as_dict=True) if res: - make_stock_entry_detail(entry, res) + make_stock_entry_detail(entry, res, cancelled, uncancelled) if cancelled or uncancelled: - send_email() + send_email(cancelled, uncancelled) -def make_stock_entry_detail(entry, res): - global cancelled, uncancelled - +def make_stock_entry_detail(entry, res, cancelled, uncancelled): fg_item = webnotes.conn.get_value("Production Order", entry.production_order, "production_item") voucher_detail_entries_map = {} @@ -87,9 +84,8 @@ def make_stock_entry_detail(entry, res): uncancelled.append(se.doc.name) -def send_email(): +def send_email(cancelled, uncancelled): from webnotes.utils.email_lib import sendmail_to_system_managers - global cancelled, uncancelled uncancelled = "we have undone the cancellation of the following Stock Entries through a patch:\n" + \ "\n".join(uncancelled) if uncancelled else "" cancelled = "and cancelled the following Stock Entries:\n" + "\n".join(cancelled) \ diff --git a/patches/october_2013/p04_wsgi_migration.py b/patches/october_2013/p04_wsgi_migration.py new file mode 100644 index 0000000000..ca73516c25 --- /dev/null +++ b/patches/october_2013/p04_wsgi_migration.py @@ -0,0 +1,30 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes +import webnotes.utils +import os + +def execute(): + base_path = webnotes.utils.get_base_path() + + # Remove symlinks from public folder: + # - server.py + # - web.py + # - unsupported.html + # - blank.html + # - rss.xml + # - sitemap.xml + for file in ("server.py", "web.py", "unsupported.html", "blank.html", "rss.xml", "sitemap.xml"): + file_path = os.path.join(base_path, "public", file) + if os.path.exists(file_path): + os.remove(file_path) + + # Remove wn-web files + # - js/wn-web.js + # - css/wn-web.css + for file_path in (("js", "wn-web.js"), ("css", "wn-web.css")): + file_path = os.path.join(base_path, "public", *file_path) + if os.path.exists(file_path): + os.remove(file_path) \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index a5693854e5..92dd52742c 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -224,4 +224,5 @@ patch_list = [ "patches.october_2013.p02_set_communication_status", "patches.october_2013.p03_crm_update_status", "execute:webnotes.delete_doc('DocType', 'Setup Control')", + "patches.october_2013.p04_wsgi_migration", ] \ No newline at end of file diff --git a/utilities/demo/make_demo.py b/utilities/demo/make_demo.py index d335528dfc..219ce86496 100644 --- a/utilities/demo/make_demo.py +++ b/utilities/demo/make_demo.py @@ -75,7 +75,7 @@ def _simulate(): for i in xrange(runs_for): print current_date.strftime("%Y-%m-%d") - webnotes.utils.current_date = current_date + webnotes.local.current_date = current_date if current_date.weekday() in (5, 6): current_date = webnotes.utils.add_days(current_date, 1) diff --git a/utilities/demo/make_erpnext_demo.py b/utilities/demo/make_erpnext_demo.py index d67fb5ece0..bc25d5e34d 100644 --- a/utilities/demo/make_erpnext_demo.py +++ b/utilities/demo/make_erpnext_demo.py @@ -6,8 +6,8 @@ import webnotes, os import utilities.demo.make_demo def make_demo_app(site=None): - webnotes.flags.mute_emails = 1 webnotes.init(site=site) + webnotes.flags.mute_emails = 1 utilities.demo.make_demo.make(reset=True, simulate=False) # setup demo user etc so that the site it up faster, while the data loads