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