{"body":"UNHANDLED EXCEPTION (2015-12-06 12:48:58.078455)\nBRANCH: develop TIP: c11f7b2d299d\nPROCESS: ./scripts/noc-web.py\nERROR FINGERPRINT: f2cb0e28-d73d-5a83-998a-b1a0de025652\nWORKING DIRECTORY: /opt/noc\nEXCEPTION: <type 'exceptions.ValueError'> invalid literal for int() with base 10: 'admin'\nSTART OF TRACEBACK\n------------------------------------------------------------------------\nFile: local/lib/python2.7/site-packages/django/db/models/fields/__init__.py (Line: 537)\nFunction: get_prep_value\n  530     \n  531         def validate(self, value, model_instance):\n  532             pass\n  533     \n  534         def get_prep_value(self, value):\n  535             if value is None:\n  536                 return None\n  537 ==>         return int(value)\n  538     \n  539         def contribute_to_class(self, cls, name):\n  540             assert not cls._meta.has_auto_field, \\\n  541                    \"A model can't have more than one AutoField.\"\n  542             super(AutoField, self).contribute_to_class(cls, name)\n  543             cls._meta.has_auto_field = True\nVariables:\n                self = <django.db.models.fields.AutoField: id>\n               value = 'admin'\n------------------------------------------------------------------------\nFile: local/lib/python2.7/site-packages/django/db/models/fields/__init__.py (Line: 310)\nFunction: get_prep_lookup\n  303             if lookup_type in (\n  304                     'regex', 'iregex', 'month', 'day', 'week_day', 'search',\n  305                     'contains', 'icontains', 'iexact', 'startswith', 'istartswith',\n  306                     'endswith', 'iendswith', 'isnull'\n  307                 ):\n  308                 return value\n  309             elif lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte'):\n  310 ==>             return self.get_prep_value(value)\n  311             elif lookup_type in ('range', 'in'):\n  312                 return [self.get_prep_value(v) for v in value]\n  313             elif lookup_type == 'year':\n  314                 try:\n  315                     return int(value)\n  316                 except ValueError:\nVariables:\n         lookup_type = 'exact'\n                self = <django.db.models.fields.AutoField: id>\n               value = 'admin'\n------------------------------------------------------------------------\nFile: local/lib/python2.7/site-packages/django/db/models/fields/related.py (Line: 210)\nFunction: _pk_trace\n  203                 if hasattr(field.rel, 'field_name'):\n  204                     field = field.rel.to._meta.get_field(field.rel.field_name)\n  205                 else:\n  206                     field = field.rel.to._meta.pk\n  207     \n  208             if lookup_type in ('range', 'in'):\n  209                 v = [v]\n  210 ==>         v = getattr(field, prep_func)(lookup_type, v, **kwargs)\n  211             if isinstance(v, list):\n  212                 v = v[0]\n  213             return v\n  214     \n  215         def related_query_name(self):\n  216             # This method defines the name that can be used to identify this\nVariables:\n                   v = 'admin'\n         lookup_type = 'exact'\n           prep_func = 'get_prep_lookup'\n               value = 'admin'\n               field = <django.db.models.fields.AutoField: id>\n              kwargs = {}\n          field_name = None\n                self = <django.db.models.fields.related.ForeignKey: user>\n------------------------------------------------------------------------\nFile: local/lib/python2.7/site-packages/django/db/models/fields/related.py (Line: 137)\nFunction: get_prep_lookup\n  130             if hasattr(value, '_prepare'):\n  131                 return value._prepare()\n  132             # FIXME: lt and gt are explicitly allowed to make\n  133             # get_(next/prev)_by_date work; other lookups are not allowed since that\n  134             # gets messy pretty quick. This is a good candidate for some refactoring\n  135             # in the future.\n  136             if lookup_type in ['exact', 'gt', 'lt', 'gte', 'lte']:\n  137 ==>             return self._pk_trace(value, 'get_prep_lookup', lookup_type)\n  138             if lookup_type in ('range', 'in'):\n  139                 return [self._pk_trace(v, 'get_prep_lookup', lookup_type) for v in value]\n  140             elif lookup_type == 'isnull':\n  141                 return []\n  142             raise TypeError(\"Related Field has invalid lookup: %s\" % lookup_type)\n  143     \nVariables:\n         lookup_type = 'exact'\n                self = <django.db.models.fields.related.ForeignKey: user>\n               value = 'admin'\n------------------------------------------------------------------------\nFile: local/lib/python2.7/site-packages/django/db/models/sql/where.py (Line: 320)\nFunction: prepare\n  313             if model is not None:\n  314                 self.field = model._meta.get_field(field_name)\n  315             else:\n  316                 self.field = None\n  317     \n  318         def prepare(self, lookup_type, value):\n  319             if self.field:\n  320 ==>             return self.field.get_prep_lookup(lookup_type, value)\n  321             return value\n  322     \n  323         def process(self, lookup_type, value, connection):\n  324             \"\"\"\n  325             Returns a tuple of data suitable for inclusion in a WhereNode\n  326             instance.\nVariables:\n         lookup_type = 'exact'\n                self = <django.db.models.sql.where.Constraint object at 0x7f8864e2d1d0>\n               value = 'admin'\n------------------------------------------------------------------------\nFile: local/lib/python2.7/site-packages/django/db/models/sql/where.py (Line: 69)\nFunction: add\n   62                 value_annotation = datetime.datetime\n   63             elif hasattr(value, 'value_annotation'):\n   64                 value_annotation = value.value_annotation\n   65             else:\n   66                 value_annotation = bool(value)\n   67     \n   68             if hasattr(obj, \"prepare\"):\n   69 ==>             value = obj.prepare(lookup_type, value)\n   70     \n   71             super(WhereNode, self).add(\n   72                     (obj, lookup_type, value_annotation, value), connector)\n   73     \n   74         def as_sql(self, qn, connection):\n   75             \"\"\"\nVariables:\n    value_annotation = True\n                 obj = <django.db.models.sql.where.Constraint object at 0x7f8864e2d1d0>\n         lookup_type = 'exact'\n               value = 'admin'\n           connector = 'AND'\n                data = \n(<django.db.models.sql.where.Constraint object at 0x7f8864e2d1d0>,\n 'exact',\n 'admin')\n                self = <django.db.models.sql.where.WhereNode object at 0x7f8864e2d090>\n------------------------------------------------------------------------\nFile: local/lib/python2.7/site-packages/django/db/models/sql/query.py (Line: 1185)\nFunction: add_filter\n 1178             if having_clause or force_having:\n 1179                 if (alias, col) not in self.group_by:\n 1180                     self.group_by.append((alias, col))\n 1181                 self.having.add((Constraint(alias, col, field), lookup_type, value),\n 1182                     connector)\n 1183             else:\n 1184                 self.where.add((Constraint(alias, col, field), lookup_type, value),\n 1185 ==>                 connector)\n 1186     \n 1187             if negate:\n 1188                 self.promote_alias_chain(join_list)\n 1189                 if lookup_type != 'isnull':\n 1190                     if len(join_list) > 1:\n 1191                         for alias in join_list:\nVariables:\n       having_clause = False\n                trim = False\n           num_parts = 1\n                 arg = 'user'\n              negate = False\n           connector = 'AND'\n      process_extras = True\n                self = <django.db.models.sql.query.Query object at 0x7f8864e2de10>\n       table_promote = False\n               field = <django.db.models.fields.related.ForeignKey: user>\n               parts = ['user']\n         filter_expr = ('user', 'admin')\n        join_promote = False\n        force_having = False\n           join_list = ['main_userprofile']\n  nonnull_comparison = False\n           can_reuse = set([])\n          allow_many = True\n                last = []\n              target = <django.db.models.fields.AutoField: id>\n         lookup_type = 'exact'\n               value = 'admin'\n               alias = 'main_userprofile'\n       extra_filters = []\n                 col = 'user_id'\n                opts = <Options for User>\n------------------------------------------------------------------------\nFile: local/lib/python2.7/site-packages/django/db/models/sql/query.py (Line: 1250)\nFunction: add_q\n 1243                         self.having.start_subtree(connector)\n 1244                     else:\n 1245                         self.where.start_subtree(connector)\n 1246                     if isinstance(child, Node):\n 1247                         self.add_q(child, used_aliases, force_having=force_having)\n 1248                     else:\n 1249                         self.add_filter(child, connector, q_object.negated,\n 1250 ==>                             can_reuse=used_aliases, force_having=force_having)\n 1251                     if force_having:\n 1252                         self.having.end_subtree()\n 1253                     else:\n 1254                         self.where.end_subtree()\n 1255     \n 1256                     if connector == OR:\nVariables:\n        used_aliases = set([])\n        force_having = False\n            q_object = <django.db.models.query_utils.Q object at 0x7f8864e2d2d0>\n                self = <django.db.models.sql.query.Query object at 0x7f8864e2de10>\n             subtree = False\n           connector = 'AND'\n               child = ('user', 'admin')\n------------------------------------------------------------------------\nFile: local/lib/python2.7/site-packages/django/db/models/query.py (Line: 642)\nFunction: _filter_or_exclude\n  635                 assert self.query.can_filter(), \\\n  636                         \"Cannot filter a query once a slice has been taken.\"\n  637     \n  638             clone = self._clone()\n  639             if negate:\n  640                 clone.query.add_q(~Q(*args, **kwargs))\n  641             else:\n  642 ==>             clone.query.add_q(Q(*args, **kwargs))\n  643             return clone\n  644     \n  645         def complex_filter(self, filter_obj):\n  646             \"\"\"\n  647             Returns a new QuerySet instance with filter_obj added to the filters.\n  648     \nVariables:\n              negate = False\n               clone = [<UserProfile: admin's Profile>]\n                args = ()\n                self = [<UserProfile: admin's Profile>]\n              kwargs = {'user': 'admin'}\n------------------------------------------------------------------------\nFile: local/lib/python2.7/site-packages/django/db/models/query.py (Line: 624)\nFunction: filter\n  617             return self._clone()\n  618     \n  619         def filter(self, *args, **kwargs):\n  620             \"\"\"\n  621             Returns a new QuerySet instance with the args ANDed to the existing\n  622             set.\n  623             \"\"\"\n  624 ==>         return self._filter_or_exclude(False, *args, **kwargs)\n  625     \n  626         def exclude(self, *args, **kwargs):\n  627             \"\"\"\n  628             Returns a new QuerySet instance with NOT (args) ANDed to the existing\n  629             set.\n  630             \"\"\"\nVariables:\n                self = [<UserProfile: admin's Profile>]\n                args = ()\n              kwargs = {'user': 'admin'}\n------------------------------------------------------------------------\nFile: local/lib/python2.7/site-packages/django/db/models/query.py (Line: 358)\nFunction: get\n  351             return self.query.get_count(using=self.db)\n  352     \n  353         def get(self, *args, **kwargs):\n  354             \"\"\"\n  355             Performs the query and returns a single object matching the given\n  356             keyword arguments.\n  357             \"\"\"\n  358 ==>         clone = self.filter(*args, **kwargs)\n  359             if self.query.can_filter():\n  360                 clone = clone.order_by()\n  361             num = len(clone)\n  362             if num == 1:\n  363                 return clone._result_cache[0]\n  364             if not num:\nVariables:\n                self = [<UserProfile: admin's Profile>]\n                args = ()\n              kwargs = {'user': 'admin'}\n------------------------------------------------------------------------\nFile: local/lib/python2.7/site-packages/django/db/models/manager.py (Line: 131)\nFunction: get\n  124         def distinct(self, *args, **kwargs):\n  125             return self.get_query_set().distinct(*args, **kwargs)\n  126     \n  127         def extra(self, *args, **kwargs):\n  128             return self.get_query_set().extra(*args, **kwargs)\n  129     \n  130         def get(self, *args, **kwargs):\n  131 ==>         return self.get_query_set().get(*args, **kwargs)\n  132     \n  133         def get_or_create(self, **kwargs):\n  134             return self.get_query_set().get_or_create(**kwargs)\n  135     \n  136         def create(self, **kwargs):\n  137             return self.get_query_set().create(**kwargs)\nVariables:\n                self = \n<noc.main.models.userprofile.UserProfileManager object at 0x7f886a4dffd0>\n                args = ()\n              kwargs = {'user': 'admin'}\n------------------------------------------------------------------------\nFile: lib/csvutils.py (Line: 178)\nFunction: csv_import\n  171                 if not v:\n  172                     del vars[h]\n  173                 else:\n  174                     if h in fk:\n  175                         # reference foreign keys\n  176                         rel, rname = fk[h]\n  177                         try:\n  178 ==>                         ro = rel.objects.get(**{rname: v})\n  179                         except rel.DoesNotExist:\n  180                             # Failed to reference by name, fallback to id\n  181                             try:\n  182                                 id = int(v)\n  183                             except ValueError:\n  184                                 return None, \"Cannot resolve '%s' in field '%s' at line '%s'\" % (v, h, count)\nVariables:\n               rname = 'user'\n            l_header = 4\n                vars = \n{'notification_method': 'mail',\n 'params': 'test@example.com',\n 'time_pattern': <TimePattern: Any>,\n 'user_profile': 'admin'}\n                  ir = set(['id'])\n              header = ['user_profile', 'time_pattern', 'notification_method', 'params']\n       unique_fields = set(['id'])\n                 row = ['admin', 'Any', 'mail', 'test@example.com']\n           ut_fields = [('user_profile', 'time_pattern', 'notification_method', 'params')]\n            u_fields = []\n     required_fields = set(['notification_method', 'params', 'time_pattern', 'user_profile'])\n                 rel = <class 'noc.main.models.userprofile.UserProfile'>\n              reader = <_csv.reader object at 0x7f8864d8c9f0>\n                  ro = <TimePattern: Any>\n                  fs = ('user_profile', 'time_pattern', 'notification_method', 'params')\n            booleans = set([])\n                  fk = \n{'time_pattern': (<class 'noc.main.models.timepattern.TimePattern'>, 'name'),\n 'user_profile': (<class 'noc.main.models.userprofile.UserProfile'>, 'user')}\n               model = <class 'noc.main.models.userprofilecontact.UserProfileContact'>\n               count = 1\n            integers = set([])\n                name = 'params'\n                   f = 'params'\n                   h = 'user_profile'\n            required = True\n           delimiter = ','\n                   v = 'admin'\n         field_names = set(['notification_method', 'params', 'time_pattern', 'user_profile'])\n          resolution = u'2'\n                left = set([])\n------------------------------------------------------------------------\nFile: main/apps/csv/views.py (Line: 85)\nFunction: view_import\n   78             \"\"\"\n   79             a, m = model.split(\".\")\n   80             m = get_object_or_404(ContentType, app_label=a, model=m).model_class()\n   81             if request.POST:\n   82                 form = self.ImportForm(request.POST, request.FILES)\n   83                 if form.is_valid():\n   84                     count, error = csv_import(m, request.FILES[\"file\"],\n   85 ==>                                         resolution=form.cleaned_data[\"resolve\"])\n   86                     if error:\n   87                         # Rollback current transaction to be able to send message\n   88                         transaction.rollback()\n   89                     if count is None:\n   90                         self.message_user(request,\n   91                                           \"Error importing data: %s\" % error)\nVariables:\n                   a = u'main'\n                form = <noc.main.apps.csv.views.ImportForm object at 0x7f8864e2d0d0>\n                   m = <class 'noc.main.models.userprofilecontact.UserProfileContact'>\n                self = <noc.main.apps.csv.views.CSVApplication object at 0x7f8868187050>\n             request = \n<WSGIRequest\npath:/main/csv/import/main.userprofilecontact/,\nGET:<QueryDict: {}>,\nPOST:<QueryDict: {u'resolve': [u'2'], u'referer': [u'http://10.50.64.73/main/csv/']}>,\nCOOKIES:{'csrftoken': 'gm4OMRGU99Z4NLDGxminDxuKFkxYl9xs',\n 'sessionid': 'bc48681ce61d25e0ded1391d2f5e3ebd'},\nMETA:{'CONTENT_LENGTH': '676',\n 'CONTENT_TYPE': 'multipart/form-data; boundary=---------------------------20803397213277862861334412507',\n 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',\n 'HTTP_ACCEPT_ENCODING': 'gzip, deflate',\n 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.5',\n 'HTTP_CONNECTION': 'close',\n 'HTTP_COOKIE': 'sessionid=bc48681ce61d25e0ded1391d2f5e3ebd; csrftoken=gm4OMRGU99Z4NLDGxminDxuKFkxYl9xs',\n 'HTTP_HOST': '10.50.64.73',\n 'HTTP_REFERER': 'http://10.50.64.73/main/csv/import/main.userprofilecontact/',\n 'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0',\n 'HTTP_X_SCHEME': 'http',\n 'PATH_INFO': u'/main/csv/import/main.userprofilecontact/',\n 'QUERY_STRING': '',\n 'REMOTE_ADDR': '127.0.0.1',\n 'REQUEST_METHOD': 'POST',\n 'SCRIPT_NAME': u'',\n 'SERVER_NAME': '10.50.64.73',\n 'SERVER_PORT': '80',\n 'SERVER_PROTOCOL': 'HTTP/1.0',\n 'wsgi.errors': <open file '/dev/null', mode 'a+' at 0x7f886e439390>,\n 'wsgi.input': <_io.BytesIO object at 0x7f8864deafb0>,\n 'wsgi.multiprocess': True,\n 'wsgi.multithread': False,\n 'wsgi.run_once': False,\n 'wsgi.url_scheme': 'http',\n 'wsgi.version': (1, 0)}>\n               model = u'main.userprofilecontact'\n------------------------------------------------------------------------\nFile: lib/app/site.py (Line: 249)\nFunction: inner\n  242                             a = dict((k, v[0] if len(v) == 1 else v)\n  243                                      for k, v in request.GET.lists())\n  244                         app_logger.debug(\"API %s %s %s\",\n  245                                          request.method, request.path, a)\n  246                     # Call handler\n  247                     v.__dict__[\"hits_metric\"] += 1\n  248                     with v.__dict__[\"time_metric\"].timer():\n  249 ==>                     r = v(request, *args, **kwargs)\n  250                     # Dump SQL statements\n  251                     if self.log_sql_statements:\n  252                         from django.db import connections\n  253                         tsc = 0\n  254                         sc = defaultdict(int)\n  255                         for conn in connections.all():\nVariables:\n                args = ()\n            view_map = \n{'DELETE': <bound method CSVApplication.view_import of <noc.main.apps.csv.views.CSVApplication object at 0x7f8868187050>>,\n 'GET': <bound method CSVApplication.view_import of <noc.main.apps.csv.views.CSVApplication object at 0x7f8868187050>>,\n 'POST': <bound method CSVApplication.view_import of <noc.main.apps.csv.views.CSVApplication object at 0x7f8868187050>>,\n 'PUT': <bound method CSVApplication.view_import of <noc.main.apps.csv.views.CSVApplication object at 0x7f8868187050>>}\n                Form = <class 'django.forms.forms.Form'>\n    PermissionDenied = <class 'noc.lib.app.access.PermissionDenied'>\n       DictParameter = <class 'noc.sa.interfaces.base.DictParameter'>\n                self = <noc.lib.app.site.Site object at 0x7f886a7952d0>\n                   v = \n<bound method CSVApplication.view_import of <noc.main.apps.csv.views.CSVApplication object at 0x7f8868187050>>\n             request = \n<WSGIRequest\npath:/main/csv/import/main.userprofilecontact/,\nGET:<QueryDict: {}>,\nPOST:<QueryDict: {u'resolve': [u'2'], u'referer': [u'http://10.50.64.73/main/csv/']}>,\nCOOKIES:{'csrftoken': 'gm4OMRGU99Z4NLDGxminDxuKFkxYl9xs',\n 'sessionid': 'bc48681ce61d25e0ded1391d2f5e3ebd'},\nMETA:{'CONTENT_LENGTH': '676',\n 'CONTENT_TYPE': 'multipart/form-data; boundary=---------------------------20803397213277862861334412507',\n 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',\n 'HTTP_ACCEPT_ENCODING': 'gzip, deflate',\n 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.5',\n 'HTTP_CONNECTION': 'close',\n 'HTTP_COOKIE': 'sessionid=bc48681ce61d25e0ded1391d2f5e3ebd; csrftoken=gm4OMRGU99Z4NLDGxminDxuKFkxYl9xs',\n 'HTTP_HOST': '10.50.64.73',\n 'HTTP_REFERER': 'http://10.50.64.73/main/csv/import/main.userprofilecontact/',\n 'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0',\n 'HTTP_X_SCHEME': 'http',\n 'PATH_INFO': u'/main/csv/import/main.userprofilecontact/',\n 'QUERY_STRING': '',\n 'REMOTE_ADDR': '127.0.0.1',\n 'REQUEST_METHOD': 'POST',\n 'SCRIPT_NAME': u'',\n 'SERVER_NAME': '10.50.64.73',\n 'SERVER_PORT': '80',\n 'SERVER_PROTOCOL': 'HTTP/1.0',\n 'wsgi.errors': <open file '/dev/null', mode 'a+' at 0x7f886e439390>,\n 'wsgi.input': <_io.BytesIO object at 0x7f8864deafb0>,\n 'wsgi.multiprocess': True,\n 'wsgi.multithread': False,\n 'wsgi.run_once': False,\n 'wsgi.url_scheme': 'http',\n 'wsgi.version': (1, 0)}>\n          app_logger = <logging.Logger object at 0x7f8868187090>\n  InterfaceTypeError = <class 'noc.sa.interfaces.base.InterfaceTypeError'>\n     to_log_api_call = False\n              kwargs = {'model': u'main.userprofilecontact'}\n                  nq = <function nq at 0x7f8864d1c758>\n                 app = <noc.main.apps.csv.views.CSVApplication object at 0x7f8868187050>\n------------------------------------------------------------------------\nEND OF TRACEBACK","name":"","extension":"txt","url":"https://www.irccloud.com/pastebin/DLPSPiYl","modified":1449395494,"id":"DLPSPiYl","size":22574,"lines":479,"own_paste":false,"theme":"","date":1449395494}