From 8fad8f7aa80b5347348bfc68ab1c4bbd84b2ce9e Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 26 Sep 2013 11:20:55 +0530 Subject: [PATCH 01/13] [minor] mandatory error msg fix --- webnotes/model/bean.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webnotes/model/bean.py b/webnotes/model/bean.py index 18f85596a2..e6c6c78960 100644 --- a/webnotes/model/bean.py +++ b/webnotes/model/bean.py @@ -404,7 +404,7 @@ class Bean: elif doc.fields.get(df.fieldname) is None: msg = _("Error") + ": " if doc.parentfield: - msg += _("Row") + (" # %d: " % doc.idx) + msg += _("Row") + (" # %s: " % (doc.idx,)) msg += _("Value missing for") + ": " + _(df.label) From 1ff183d8e173a2c66e79289f09b61d963bc36d8e Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 26 Sep 2013 17:36:22 +0530 Subject: [PATCH 02/13] [minor] dont send notifications if scheduler fails due to connection time out --- webnotes/utils/scheduler.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/webnotes/utils/scheduler.py b/webnotes/utils/scheduler.py index d98564c52a..997a6ed399 100644 --- a/webnotes/utils/scheduler.py +++ b/webnotes/utils/scheduler.py @@ -107,7 +107,9 @@ def report_errors(): errors = [("""

Time: %(modified)s

%(error)s
""" % d) for d in webnotes.conn.sql("""select modified, error - from `tabScheduler Log` where DATEDIFF(NOW(), modified) < 1 limit 10""", as_dict=True)] + from `tabScheduler Log` where DATEDIFF(NOW(), modified) < 1 + and error not like '%%[Errno 111] Connection refused%%' + limit 10""", as_dict=True)] if errors: sendmail_to_system_managers("ERPNext Scheduler Failure Report", (""" From cd42711229a70de989a916e64bddb43b5151bace Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 26 Sep 2013 17:40:19 +0530 Subject: [PATCH 03/13] [minor] dont send notifications if scheduler fails due to connection time out --- webnotes/utils/scheduler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webnotes/utils/scheduler.py b/webnotes/utils/scheduler.py index 997a6ed399..308f4e1508 100644 --- a/webnotes/utils/scheduler.py +++ b/webnotes/utils/scheduler.py @@ -108,7 +108,7 @@ def report_errors(): errors = [("""

Time: %(modified)s

%(error)s
""" % d) for d in webnotes.conn.sql("""select modified, error from `tabScheduler Log` where DATEDIFF(NOW(), modified) < 1 - and error not like '%%[Errno 111] Connection refused%%' + and error not like '%%[Errno 110] Connection timed out%%' limit 10""", as_dict=True)] if errors: From 4e175b0331f6794e6ac3d3fdebb38370b7247f63 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Fri, 27 Sep 2013 12:35:52 +0530 Subject: [PATCH 04/13] [fix] fixes for dirty() --- public/js/legacy/form.js | 1 + 1 file changed, 1 insertion(+) diff --git a/public/js/legacy/form.js b/public/js/legacy/form.js index a5b931df9e..0c14336bde 100644 --- a/public/js/legacy/form.js +++ b/public/js/legacy/form.js @@ -131,6 +131,7 @@ _f.Frm.prototype.watch_model_updates = function() { wn.model.on(me.doctype, "*", function(fieldname, value, doc) { // set input if(doc.name===me.docname) { + me.dirty(); me.fields_dict[fieldname] && me.fields_dict[fieldname].refresh(fieldname); me.refresh_dependency(); From 03ccfcbfcf98c3f0367d43b55c0f02e78467835c Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 27 Sep 2013 15:06:18 +0530 Subject: [PATCH 05/13] [fix] [minor] unicode issue in uploading file --- webnotes/handler.py | 4 +++- webnotes/utils/__init__.py | 2 +- webnotes/utils/file_manager.py | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/webnotes/handler.py b/webnotes/handler.py index d59d235c99..132a5bdedc 100755 --- a/webnotes/handler.py +++ b/webnotes/handler.py @@ -27,7 +27,9 @@ def get_cgi_fields(): for key in webnotes.form.keys(): # file upload must not be decoded as it is treated as a binary # file and hence in any encoding (it does not matter) - if not getattr(webnotes.form[key], 'filename', None): + if key == "filedata": + webnotes.form_dict[key] = webnotes.form.getvalue(key) + else: webnotes.form_dict[key] = cstr(webnotes.form.getvalue(key)) @webnotes.whitelist(allow_guest=True) diff --git a/webnotes/utils/__init__.py b/webnotes/utils/__init__.py index ccc1aa8b6d..9eb7ceb679 100644 --- a/webnotes/utils/__init__.py +++ b/webnotes/utils/__init__.py @@ -814,7 +814,7 @@ def get_path(*path): def get_base_path(): import conf import os - return os.path.dirname(os.path.abspath(conf.__file__)) + return os.path.dirname(os.path.abspath(conf.__file__.decode("utf-8"))) def get_url(uri=None): url = get_request_site_address() diff --git a/webnotes/utils/file_manager.py b/webnotes/utils/file_manager.py index bb39a80f4e..a84dcee1aa 100644 --- a/webnotes/utils/file_manager.py +++ b/webnotes/utils/file_manager.py @@ -73,7 +73,7 @@ def save_file(fname, content, dt, dn): file_size = check_max_file_size(content) temp_fname = write_file(content, files_path) fname = scrub_file_name(fname) - fpath = os.path.join(files_path, fname).encode("utf-8") + fpath = os.path.join(files_path, fname) fname_parts = fname.split(".", -1) main = ".".join(fname_parts[:-1]) @@ -95,10 +95,10 @@ def save_file(fname, content, dt, dn): fname = get_new_fname_based_on_version(files_path, main, extn, versions) # rename - os.rename(temp_fname, fpath) + os.rename(temp_fname, fpath.encode("utf-8")) else: # rename new file - os.rename(temp_fname, fpath) + os.rename(temp_fname, fpath.encode("utf-8")) f = webnotes.bean({ "doctype": "File Data", From abb93ad8a298f65aee2eb7527a982e92a0da96b7 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 27 Sep 2013 15:30:29 +0530 Subject: [PATCH 06/13] [minor] [fix] get_file_versions --- webnotes/utils/file_manager.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/webnotes/utils/file_manager.py b/webnotes/utils/file_manager.py index a84dcee1aa..b766baea80 100644 --- a/webnotes/utils/file_manager.py +++ b/webnotes/utils/file_manager.py @@ -113,7 +113,12 @@ def save_file(fname, content, dt, dn): return f.doc def get_file_versions(files_path, main, extn): - return filter(lambda f: f.startswith(main) and f.endswith(extn), os.listdir(files_path)) + out = [] + for f in os.listdir(files_path): + f = cstr(f) + if f.startswith(main) and f.endswith(extn): + out.append(f) + return out def get_new_fname_based_on_version(files_path, main, extn, versions): versions.sort() From 3f8223ddfe8b4a8599017855c5d347c3d6c5a919 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Mon, 30 Sep 2013 12:45:43 +0530 Subject: [PATCH 07/13] [fix] [minor] dirty() fixes --- public/js/legacy/form.js | 1 + public/js/wn/form/control.js | 1 - public/js/wn/model/model.js | 11 ++++++----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/public/js/legacy/form.js b/public/js/legacy/form.js index 0c14336bde..30fc41318d 100644 --- a/public/js/legacy/form.js +++ b/public/js/legacy/form.js @@ -143,6 +143,7 @@ _f.Frm.prototype.watch_model_updates = function() { $.each(wn.model.get("DocField", {fieldtype:"Table", parent: me.doctype}), function(i, df) { wn.model.on(df.options, "*", function(fieldname, value, doc) { if(doc.parent===me.docname && doc.parentfield===df.fieldname) { + me.dirty(); me.fields_dict[df.fieldname].grid.set_value(fieldname, value, doc); me.script_manager.trigger(fieldname, doc.doctype, doc.name); } diff --git a/public/js/wn/form/control.js b/public/js/wn/form/control.js index 5ab45bc819..b2b152c923 100644 --- a/public/js/wn/form/control.js +++ b/public/js/wn/form/control.js @@ -76,7 +76,6 @@ wn.ui.form.Control = Class.extend({ set_model_value: function(value) { if(wn.model.set_value(this.doctype, this.docname, this.df.fieldname, value, this.df.fieldtype)) { - this.frm && this.frm.dirty(); this.last_value = value; } }, diff --git a/public/js/wn/model/model.js b/public/js/wn/model/model.js index 8c93e4db3d..9f8a41fa9f 100644 --- a/public/js/wn/model/model.js +++ b/public/js/wn/model/model.js @@ -207,18 +207,19 @@ $.extend(wn.model, { }, trigger: function(fieldname, value, doc) { - var run = function(events) { + var run = function(events, event_doc) { $.each(events || [], function(i, fn) { - fn && fn(fieldname, value, doc); + fn && fn(fieldname, value, event_doc || doc); }); }; if(wn.model.events[doc.doctype]) { - // doctype-level - run(wn.model.events[doc.doctype]['*']); - + // field-level run(wn.model.events[doc.doctype][fieldname]); + + // doctype-level + run(wn.model.events[doc.doctype]['*']); }; }, From 572120eb406b217fc54e8a63c6d8d5ca2327d94d Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 1 Oct 2013 17:11:39 +0530 Subject: [PATCH 08/13] [minor] change filename to unicode after os.walk and os.listdir --- .../documentation_tool/documentation_tool.py | 6 +++- requirements.txt | 31 +++++++++---------- webnotes/install_lib/install.py | 2 ++ webnotes/model/sync.py | 2 ++ webnotes/modules/utils.py | 6 +++- webnotes/test_runner.py | 2 ++ webnotes/translate.py | 5 ++- webnotes/utils/backups.py | 1 + webnotes/utils/file_manager.py | 1 + webnotes/webutils.py | 1 + 10 files changed, 38 insertions(+), 19 deletions(-) diff --git a/core/doctype/documentation_tool/documentation_tool.py b/core/doctype/documentation_tool/documentation_tool.py index b052672ced..63bf62fe2e 100644 --- a/core/doctype/documentation_tool/documentation_tool.py +++ b/core/doctype/documentation_tool/documentation_tool.py @@ -9,7 +9,7 @@ import webnotes import inspect, os, json, datetime, shutil from jinja2 import Environment, FileSystemLoader from webnotes.modules import get_doc_path, get_module_path, scrub -from webnotes.utils import get_path, get_base_path +from webnotes.utils import get_path, get_base_path, cstr class DocType: def __init__(self, d, dl): @@ -37,6 +37,7 @@ def get_static_pages(): for repo in ("lib", "app"): for basepath, folders, files in os.walk(get_path(repo, "docs")): for fname in files: + fname = cstr(fname) if fname.endswith(".md"): fpath = get_path(basepath, fname) with open(fpath, "r") as docfile: @@ -79,6 +80,7 @@ def get_docs_for(docs, name): mydocs["_toc"] = [] dirname = os.path.dirname(obj.__file__) for fname in os.listdir(dirname): + fname = cstr(fname) fpath = os.path.join(dirname, fname) if os.path.isdir(fpath): # append if package @@ -177,6 +179,7 @@ def get_modules(for_module=None): prefix = prefix + ".py_modules." for basepath, folders, files in os.walk(module_path): for f in files: + f = cstr(f) if f.endswith(".py") and \ (not f.split(".")[0] in os.path.split(basepath)) and \ (not f.startswith("__")): @@ -439,6 +442,7 @@ def write_docs(data, build_sitemap=None, domain=None): domain = domain + "/" content = "" for fname in os.listdir(get_path("public", "docs")): + fname = cstr(fname) if fname.endswith(".html"): content += sitemap_link_xml % (domain + fname, get_timestamp(get_path("public", "docs", fname))) diff --git a/requirements.txt b/requirements.txt index 4cbb27f441..640453a081 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,16 +1,15 @@ -Jinja2==2.7.1 -MarkupSafe==0.18 -MySQL-python==1.2.4 -chardet==2.1.1 -dropbox==1.6 -google-api-python-client==1.2 -httplib2==0.8 -markdown2==2.1.0 -mysql-utilities==1.3.5 -pygeoip==0.2.7 -python-dateutil==2.1 -python-memcached==1.53 -pytz==2013b -requests==1.2.3 -six==1.4.0 -termcolor==1.1.0 \ No newline at end of file +Jinja2 +MarkupSafe +MySQL-python +chardet +dropbox +google-api-python-client +httplib2 +markdown2 +pygeoip +python-dateutil +python-memcached +pytz==2013d +requests +six +termcolor \ No newline at end of file diff --git a/webnotes/install_lib/install.py b/webnotes/install_lib/install.py index e154d74fec..b945d7b73b 100755 --- a/webnotes/install_lib/install.py +++ b/webnotes/install_lib/install.py @@ -12,6 +12,7 @@ import webnotes.db import getpass from webnotes.model.db_schema import DbManager from webnotes.model.sync import sync_for +from webnotes.utils import cstr class Installer: def __init__(self, root_login, root_password=None): @@ -107,6 +108,7 @@ class Installer: print "Importing install fixtures..." for basepath, folders, files in os.walk(os.path.join("app", "startup", "install_fixtures")): for f in files: + f = cstr(f) if f.endswith(".json"): print "Importing " + f with open(os.path.join(basepath, f), "r") as infile: diff --git a/webnotes/model/sync.py b/webnotes/model/sync.py index 82f284c02c..b7a08fdda8 100644 --- a/webnotes/model/sync.py +++ b/webnotes/model/sync.py @@ -10,6 +10,7 @@ import webnotes import os import conf from webnotes.modules.import_file import import_file +from webnotes.utils import cstr def sync_all(force=0): sync_for("lib", force) @@ -33,6 +34,7 @@ def walk_and_sync(start_path, force=0, sync_everything = False): if sync_everything or (os.path.basename(os.path.dirname(path)) in document_type): for f in files: + f = cstr(f) if f.endswith(".txt"): doc_name = f.split(".txt")[0] if doc_name == os.path.basename(path): diff --git a/webnotes/modules/utils.py b/webnotes/modules/utils.py index 4bc2de2c8d..ba6e8aca10 100644 --- a/webnotes/modules/utils.py +++ b/webnotes/modules/utils.py @@ -4,6 +4,9 @@ from __future__ import unicode_literals import webnotes, os +import webnotes.modules +from webnotes.utils import cstr +from webnotes.modules import export_doc, get_module_path, scrub def listfolders(path, only_name=0): """ @@ -13,11 +16,12 @@ def listfolders(path, only_name=0): out = [] for each in os.listdir(path): + each = cstr(each) dirname = each.split(os.path.sep)[-1] fullpath = os.path.join(path, dirname) if os.path.isdir(fullpath) and not dirname.startswith('.'): - out.append(only_name and dirname or fullname) + out.append(only_name and dirname or fullpath) return out def switch_module(dt, dn, to, frm=None, export=None): diff --git a/webnotes/test_runner.py b/webnotes/test_runner.py index ed5b00f55f..2622d3be38 100644 --- a/webnotes/test_runner.py +++ b/webnotes/test_runner.py @@ -13,6 +13,7 @@ import unittest from webnotes.model.meta import has_field from webnotes.model.code import load_doctype_module, get_module_name from webnotes.model.doctype import get_link_fields +from webnotes.utils import cstr def make_test_records(doctype, verbose=0): @@ -148,6 +149,7 @@ def run_all_tests(verbose): for path, folders, files in os.walk("."): # print path for filename in files: + filename = cstr(filename) if filename.startswith("test_") and filename.endswith(".py"): print filename[:-3] webnotes.session.user = "Administrator" diff --git a/webnotes/translate.py b/webnotes/translate.py index 860eac48ba..4f22eacd49 100644 --- a/webnotes/translate.py +++ b/webnotes/translate.py @@ -17,7 +17,7 @@ import json import re from csv import reader from webnotes.modules import get_doc_path -from webnotes.utils import get_base_path +from webnotes.utils import get_base_path, cstr messages = {} @@ -116,6 +116,7 @@ def build_for_pages(path): if os.path.basename(os.path.dirname(basepath))=="page": messages_js, messages_py = [], [] for fname in files: + fname = cstr(fname) if fname.endswith('.js'): messages_js += get_message_list(os.path.join(basepath, fname)) if fname.endswith('.py'): @@ -167,6 +168,7 @@ def build_for_framework(path, mtype, with_doctype_names = False): messages = [] for (basepath, folders, files) in os.walk(path): for fname in files: + fname = cstr(fname) if fname.endswith('.' + mtype): messages += get_message_list(os.path.join(basepath, fname)) @@ -192,6 +194,7 @@ def build_from_doctype_code(path): messagespy = [] messagesjs = [] for fname in files: + fname = cstr(fname) if fname.endswith('py'): messagespy += get_message_list(os.path.join(basepath, fname)) if fname.endswith('js'): diff --git a/webnotes/utils/backups.py b/webnotes/utils/backups.py index 5c2e47c5f5..05bcd0a27b 100644 --- a/webnotes/utils/backups.py +++ b/webnotes/utils/backups.py @@ -62,6 +62,7 @@ class BackupGenerator: def get_recent_backup(self, older_than): file_list = os.listdir(get_backup_path()) for this_file in file_list: + this_file = cstr(this_file) this_file_path = os.path.join(get_backup_path(), this_file) if not is_file_old(this_file_path, older_than): if "_files" in this_file_path: diff --git a/webnotes/utils/file_manager.py b/webnotes/utils/file_manager.py index b766baea80..8b60cee530 100644 --- a/webnotes/utils/file_manager.py +++ b/webnotes/utils/file_manager.py @@ -194,6 +194,7 @@ def get_file(fname): # check in folders for basepath, folders, files in os.walk(files_path): if file_name in files: + file_name = cstr(file_name) file_path = os.path.join(basepath, file_name) break diff --git a/webnotes/webutils.py b/webnotes/webutils.py index 8263aa1633..d066dc2327 100644 --- a/webnotes/webutils.py +++ b/webnotes/webutils.py @@ -173,6 +173,7 @@ def build_website_sitemap_config(): for path, folders, files in os.walk(basepath, followlinks=True): if os.path.basename(path)=="pages" and os.path.basename(os.path.dirname(path))=="templates": for fname in files: + fname = webnotes.utils.cstr(fname) if fname.endswith(".html"): options = get_options(path, fname) config["pages"][options.link_name] = options From 5deba84b364ed1c84391b1790240d741f9d037ef Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 1 Oct 2013 17:42:45 +0530 Subject: [PATCH 09/13] [minor] fixes in get_base_path --- webnotes/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webnotes/utils/__init__.py b/webnotes/utils/__init__.py index 9eb7ceb679..ccc1aa8b6d 100644 --- a/webnotes/utils/__init__.py +++ b/webnotes/utils/__init__.py @@ -814,7 +814,7 @@ def get_path(*path): def get_base_path(): import conf import os - return os.path.dirname(os.path.abspath(conf.__file__.decode("utf-8"))) + return os.path.dirname(os.path.abspath(conf.__file__)) def get_url(uri=None): url = get_request_site_address() From d8e51e43cc585188a94ca3a6e16fb2ddc37d46d1 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 2 Oct 2013 10:45:58 +0530 Subject: [PATCH 10/13] [minor] import cstr --- webnotes/utils/backups.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webnotes/utils/backups.py b/webnotes/utils/backups.py index 05bcd0a27b..db49cb25af 100644 --- a/webnotes/utils/backups.py +++ b/webnotes/utils/backups.py @@ -13,7 +13,7 @@ from __future__ import unicode_literals #Imports import os, webnotes from datetime import datetime - +from webnotes.utils import cstr #Global constants verbose = 0 From fb3c9b15d88f2dad9fd233d67330c5c99a84cbe9 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 2 Oct 2013 11:28:11 +0530 Subject: [PATCH 11/13] [minor] [fix] POP3Mailbox use ssl --- webnotes/utils/email_lib/receive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webnotes/utils/email_lib/receive.py b/webnotes/utils/email_lib/receive.py index fe101ee2c4..2d760c054b 100644 --- a/webnotes/utils/email_lib/receive.py +++ b/webnotes/utils/email_lib/receive.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import webnotes -from webnotes.utils import extract_email_id, convert_utc_to_user_timezone, now +from webnotes.utils import extract_email_id, convert_utc_to_user_timezone, now, cint class IncomingMail: """ @@ -130,7 +130,7 @@ class POP3Mailbox: def connect(self): import poplib - if self.settings.use_ssl: + if cint(self.settings.use_ssl): self.pop = poplib.POP3_SSL(self.settings.host) else: self.pop = poplib.POP3(self.settings.host) From de538641e46ba36a5b0781e152f57fc1c7b7a2c1 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 2 Oct 2013 12:56:02 +0530 Subject: [PATCH 12/13] [minor] [fix] default conf.py --- conf/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/conf.py b/conf/conf.py index 0de8a0297a..09984c7a86 100644 --- a/conf/conf.py +++ b/conf/conf.py @@ -15,10 +15,10 @@ files_path = 'public/files' max_file_size = 1000000 # generate schema (.txt files) -developer_mode = 1 +developer_mode = 0 # clear cache on refresh -auto_cache_clear = 1 +auto_cache_clear = 0 # email logs to admin (beta) admin_email_notification = 0 From 1dc6d08cefe2acc85badfa20cefa5833fc559f3f Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 2 Oct 2013 15:04:03 +0530 Subject: [PATCH 13/13] [minor] [fix] render grid only if it is visiable --- public/js/wn/form/grid.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/public/js/wn/form/grid.js b/public/js/wn/form/grid.js index df17afd835..31f29ade7e 100644 --- a/public/js/wn/form/grid.js +++ b/public/js/wn/form/grid.js @@ -47,7 +47,9 @@ wn.ui.form.Grid = Class.extend({ this.docfields = wn.meta.get_docfields(this.doctype, this.frm.docname); this.display_status = wn.perm.get_field_display_status(this.df, this.frm.doc, this.perm); - + + if(this.display_status==="None") return; + if(!force && this.data_rows_are_same(data)) { // soft refresh this.header_row.refresh(); @@ -146,7 +148,8 @@ wn.ui.form.Grid = Class.extend({ return this.fieldinfo[fieldname]; }, set_value: function(fieldname, value, doc) { - this.grid_rows_by_docname[doc.name].refresh_field(fieldname); + if(this.display_status!=="None") + this.grid_rows_by_docname[doc.name].refresh_field(fieldname); }, add_new_row: function(idx, callback, show) { if(this.is_editable()) {