diff options
author | Nikita Karetnikov <nikita.karetnikov@gmail.com> | 2012-08-20 09:28:51 +0400 |
---|---|---|
committer | Nikita Karetnikov <nikita.karetnikov@gmail.com> | 2012-08-20 09:31:02 +0400 |
commit | 914f6627ed23d7ea01cd09a429193dbe5753a0da (patch) | |
tree | 10fcdd60ec3aa6246a3194ce2b259112ec539e1d /gstudio/management/commands | |
parent | dd1452672d65fdc3f52d8efef6d86e42abb9d95e (diff) | |
download | gnowsys-914f6627ed23d7ea01cd09a429193dbe5753a0da.tar.gz |
Fixed error messages; instance option
Diffstat (limited to 'gstudio/management/commands')
-rw-r--r-- | gstudio/management/commands/sync-instances.py | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/gstudio/management/commands/sync-instances.py b/gstudio/management/commands/sync-instances.py index 632e9ef..20607bb 100644 --- a/gstudio/management/commands/sync-instances.py +++ b/gstudio/management/commands/sync-instances.py @@ -20,10 +20,6 @@ import re import sys from datetime import datetime -from objectapp.models import Gbobject -from objectapp.models import Objecttype -from objectapp.models import Attributetype -from objectapp.models import Relationtype from objectapp.models import ObjectDoesNotExist # from gstudio.xmlrpc.metaweblog import class_checker @@ -40,7 +36,9 @@ class Command(BaseCommand): """Gets all Gbobjects from a specified server""" option_list = BaseCommand.option_list + ( make_option("--server", action="store", type="string", - dest="server", help="Specify an ip"),) + dest="server", help="Specify IP address or URI"), + make_option("--instance", action="store", type="string", + dest="instance", help="Specify an instance"),) def handle(self, *args, **options): def class_checker(m): @@ -83,8 +81,9 @@ class Command(BaseCommand): def str_to_int(string): return [int(x) for x in string] + # Weird check for DateTime objects + for key in i.keys(): - # Weird check for DateTime objects if "make_comparable" in dir(i[key]): dt = DateTime().make_comparable(i[key])[1] dt = str_to_int(group(re.search(pattern, dt))) @@ -94,19 +93,31 @@ class Command(BaseCommand): class_checker(module)[instance](**i).save() except (ObjectDoesNotExist, IntegrityError): - sys.stderr.write("Object matching query does not exist\n") + sys.stderr.write("sync-instances.py:55: " + "Object matching query does not exist\n") except ValueError: - sys.stderr.write("Object already exists\n") + sys.stderr.write("sync-instances.py:93: " + "Object already exists\n") server = options["server"] srv = ServerProxy(server, allow_none=True) + instance = options["instance"] + objcc = class_checker(objmodels) gstcc = class_checker(gstmodels) - for i in objcc.keys(): - parse("objectapp.models", i) + if instance: + if instance in objkeys: + parse("objectapp.models", instance) + + if instance in gstkeys: + parse("gstudio.models", instance) + + else: + for i in objkeys: + parse("objectapp.models", i) - for i in gstcc.keys(): - parse("gstudio.models", i) + for i in gstkeys: + parse("gstudio.models", i) |