def update_dedicated_user_service(request): if request.method == 'POST': service_id = request.POST.get('si') name = request.POST.get('s') price = request.POST.get('pr') ip = request.POST.get('i') if not validate_integer(service_id): return send_error(request, _('invalid service')) if not DedicatedUserService.objects.filter(pk=service_id).exists(): return send_error(request, _('no such service')) if not validate_empty_str(name): return send_error(request, _('please enter service')) if not validate_integer(price): return send_error(request, _('please enter valid price')) if not validate_empty_str(ip): return send_error(request, _('please enter ip')) x = DedicatedUserService.objects.get(pk=service_id) x.price = int(price) x.service = name x.ip_pool = ip x.save() if check_ajax(request): return HttpResponse('200') return redirect( reverse(view_dedicated_user_service) + '?u=%s' % x.user_id) return send_error(request, _('invalid method'))
def assign_username(self, username, password, user_id): if not validate_empty_str(username): return False if not validate_empty_str(password): return False try: auth = self.auth_params auth['user_id'] = str(user_id) if self.ibs_type == 0: user_pass = {'normal_username': username, 'normal_password': password, 'normal_generate_password': 0, 'normal_save_usernames': 0, 'normal_generate_password_len': 0 } elif self.ibs_type == 1: user_pass = {'normal_user_spec': {'normal_username': username, 'normal_password': password}} else: return False auth['attrs'] = user_pass auth['to_del_attrs'] = {} self.proxy.user.updateUserAttrs(auth) return True except xmlrpclib.Fault as f: print f.faultString return False
def __init__(self, host=None, port=None, username=None, password=None, ibs_type=1): if not validate_empty_str(host): self.hostname = read_config('ibs_address', '212.16.80.145') else: self.hostname = host if not validate_integer(port): self.port = read_config('ibs_port', '1235') else: self.port = port if not validate_empty_str(username): self.username = read_config('ibs_username', 'CRM') else: # log.debug('Setting the username') self.username = username if not validate_empty_str(password): # log.debug('Password is empty') self.password = read_config('ibs_password', '!@#CRM!@#') else: # log.debug('Setting the password') self.password = password self.proxy = xmlrpclib.ServerProxy('http://{0}:{1}/'.format(self.hostname, self.port)) self.auth_params = {"auth_name": self.username, 'auth_pass': self.password, 'auth_type': 'ADMIN'} # self.auth_params = self.__get_auth__(username, password) # print self.auth_params self.ibs_type = ibs_type
def edit_debit_subjects(request): if request.method == 'GET': sid = request.GET.get('s') subject = validate_debit_subject(sid) if not subject: return send_error(request, _('not found')) return HttpResponse( json.dumps({ 'pk': subject.pk, 'name': subject.name, 'des': subject.description })) elif request.method == 'POST': sid = request.POST.get('s') subject = validate_debit_subject(sid) if not subject: subject = DebitSubject() name = request.POST.get('n') des = request.POST.get('d') if not validate_empty_str(name): return send_error(request, _('please enter name')) if not validate_empty_str(des): return send_error(request, _('please enter description')) subject.name = name subject.description = des subject.save() return HttpResponse('200') return send_error(request, _('invalid method'))
def edit_notify_config(request): if request.method == 'GET': n = request.GET.get('n') try: if not NotifySettings.objects.filter(pk=n).exists(): return redirect(reverse(notify_configuration)) nc = NotifySettings.objects.get(pk=n) return render(request, 'notify/EditConfig.html', {'c': nc}) except Exception as e: print e.message return render(request, 'errors/ServerError.html') elif request.method == 'POST': n = request.POST.get('n') if not validate_integer(n): return redirect(reverse(notify_configuration)) email_text = request.POST.get('et') email_enabled = request.POST.get('ce') sms_text = request.POST.get('st') sms_enabled = request.POST.get('se') inbox_text = request.POST.get('it') inbox_enable = request.POST.get('ie') if email_enabled: if not validate_empty_str(email_text): return render(request, 'errors/CustomError.html', {'error_message': _('please enter email text')}) if sms_enabled: if not validate_empty_str(sms_text): return render(request, 'errors/CustomError.html', {'error_message': _('please enter sms text')}) if inbox_enable: if not validate_empty_str(inbox_text): return render(request, 'errors/CustomError.html', {'error_message': _('please enter inbox text')}) try: ns = NotifySettings.objects.get(pk=n) if email_enabled: ns.email_enabled = True ns.mail_text = email_text else: ns.email_enabled = False if sms_enabled: ns.sms_enabled = True ns.sms_text = sms_text else: ns.sms_enabled = False if inbox_enable: ns.inbox_enabled = True ns.inbox_text = inbox_text else: ns.inbox_enabled = False ns.save() fire_event(5233, ns, None, request.user.pk) return redirect(reverse(notify_configuration)) except Exception as e: print e.message return render(request, 'errors/ServerError.html') else: return render(request, 'errors/AccessDenied.html')
def update_service(self, user_id, service_name): if not user_id: return False if not validate_empty_str(service_name): return False self.update_user_attr('group_name', service_name, user_id) return True
def reference_job_to_other(request): if request.method == 'POST': job = request.POST.get('rfj') message = request.POST.get('rf') group = request.POST.get('rg') if not validate_integer(job): return _return_error_(_('invalid dashboard'), request) if not validate_empty_str(message): return _return_error_(_('please enter message'), request) if not validate_integer(group): return _return_error_(_('invalid group'), request) dash = get_current_user_dashboard(request.user, True) if int(job) not in dash: return _return_error_(_('invalid dashboard'), request) if not Group.objects.filter(pk=group).exists(): return _return_error_(_('invalid group'), request) d = Dashboard.objects.get(pk=job) if DashboardReferences.objects.filter( dashboard=d.pk, target_group_id=group, source_group_id=d.group_id).exists(): dr = DashboardReferences.objects.get(dashboard=d.pk, target_group_id=group, source_group_id=d.group_id) else: dr = DashboardReferences() if request.user.is_superuser: src_id = d.group_id else: user_groups = request.user.groups.all().values_list('pk', flat=True) if d.group_id in user_groups: src_id = d.group_id else: src_id = user_groups[0] d.last_state = 0 d.save() dr.dashboard = d dr.reason = message dst = Group.objects.get(pk=group) src = Group.objects.get(pk=src_id) dr.target_group = dst dr.source_group = src dr.user = request.user dr.save() uw = UserWorkHistory() uw.group = src uw.dashboard = d uw.message = _('job referenced to other group' ) + ' - ' + dst.name + ' - ' + message uw.start_date = now() uw.state = 5 # referenced uw.user = request.user uw.save() dc = DashboardCurrentGroup.objects.get(dashboard=d.pk) dc.group_id = group dc.save() if check_ajax(request): return HttpResponse('200') return redirect(reverse(view_dashboard) + '?j=%s' % job) return _return_error_('invalid method', request)
def edit_telegram_data(request): if request.method == 'POST': action = request.POST.get('name') uid = request.POST.get('pk') value = request.POST.get('value') if not validate_empty_str(value): if check_ajax(request): return HttpResponseBadRequest(_('please enter username')) return render(request, 'errors/CustomError.html', {'error_message': _('please enter username')}) if not validate_integer(uid): if check_ajax(request): return HttpResponseBadRequest(_('invalid user')) return render(request, 'errors/CustomError.html', {'error_message': _('invalid user')}) if not TelegramUser.objects.filter(pk=uid).exists(): if check_ajax(request): return HttpResponseBadRequest(_('no such user found!')) return render(request, 'errors/CustomError.html', {'error_message': _('no such user found')}) u = TelegramUser.objects.get(pk=uid) u.username = value u.save() if check_ajax(request): return HttpResponse('200') return redirect(reverse(view_active_users)) else: if check_ajax(request): return HttpResponseBadRequest(_('invalid method')) return redirect(reverse(view_active_users))
def get_expire_date(self, username): if not validate_empty_str(username): return None uid = self.get_user_id_by_username(username) if uid is -1: return None return self.get_expire_date_by_uid(uid)
def add_new_job_state(request): ai = check_ajax(request) if request.method == 'GET': if ai: return redirect(reverse(view_dashboard)) return redirect('/') elif request.method == 'POST': message = request.POST.get('msg') dash_id = request.POST.get('di') state = request.POST.get('s') to_edit = request.POST.get('te') if not validate_integer(dash_id): return _return_error_(_('no such data found'), request) if not validate_empty_str(message): return _return_error_(_('please enter your report'), request) if not Dashboard.objects.filter(pk=dash_id).exists(): return _return_error_(_('no such dashboard found'), request) if not validate_integer(state): state = 2 else: state = int(state) # if state > 4: # state = 4 uw = None if request.user.has_perm('CRM.change_userworkhistory'): if validate_integer(to_edit): if UserWorkHistory.objects.filter(pk=to_edit).exists(): uw = UserWorkHistory.objects.get(pk=to_edit) if state < 2: # user is trying to modify start state uw = None if not uw: uw = UserWorkHistory() dash = Dashboard.objects.get(pk=dash_id) uw.dashboard = dash # DashboardReferences.objects.get(). if request.user.is_superuser: dst = Group.objects.get(pk=dash.group_id) else: dst = Group.objects.get(pk=request.user.groups.first().pk) uw.group = dst uw.message = message uw.start_date = now() uw.user = request.user if dash.is_read: dash.last_state = state else: state = 0 uw.state = state uw.save() if state == 3 or state == 4: dash.is_done = True dash.done_date = now() remove_calendar_event(dash) dash.save() if ai: return HttpResponse('200') return redirect(reverse(view_dashboard) + '?j=%s' % dash_id) else: return render(request, 'errors/AccessDenied.html')
def update_user_attr(self, attr_name, attr_value, user_id): if not validate_empty_str(attr_name) and not validate_empty_str(attr_value): return False try: auth = self.auth_params auth['user_id'] = str(user_id) attrs = {attr_name: attr_value} auth['attrs'] = attrs auth['to_del_attrs'] = {} self.proxy.user.updateUserAttrs(auth) return True except xmlrpclib.Fault as e: print e.faultString return False except Exception as e: print e.args return False
def find_user_by_token(request): if request.method == 'GET': token = request.GET.get('tx') if not validate_empty_str(token): return HttpResponse('') if UserPolls.objects.filter(user_token=token).exists(): uid = UserPolls.objects.get(user_token=token).user.fk_ibs_user_info_user.get().ibs_uid return HttpResponse(uid) return HttpResponse('')
def create_ticket(request): if request.method == 'GET': try: dep = HelpDepartment.objects.all() return render(request, 'help_desk/CreateTicket.html', {'dep': dep}) except Exception as e: print e.message return render(request, 'errors/ServerError.html') elif request.method == 'POST': uid = request.user.pk description = request.POST.get('description') dep = request.POST.get('slDepartment') title = request.POST.get('txtTitle') if not validate_empty_str(description): return render(request, 'errors/CustomError.html', {'error_message': _('please enter description')}) if not validate_empty_str(title): return render(request, 'errors/CustomError.html', {'error_message': _('please enter title')}) if not validate_integer(dep): return render(request, 'errors/CustomError.html', {'error_message': _('please select department')}) hd = HelpDesk() hd.department = HelpDepartment.objects.get(pk=dep) hd.state = HelpDeskState.objects.get(value=0) hd.title = title hd.user = request.user hd.create_time = datetime.today() try: hd.save() t = Ticket() t.description = description t.help_desk = hd t.time = datetime.today() t.save() fire_event(3411, t, None, request.user.pk) HelpDeskTicketCreated().send(user_id=uid, title=hd.title, pk=hd.pk) return redirect(reverse(show_all_tickets)) except Exception as e: print '0x500' print e.args[1] return render(request, 'errors/ServerError.html') else: return render(request, 'errors/AccessDenied.html')
def add_new_poll(request): if request.method == 'POST': name = request.POST.get('n') description = request.POST.get('d') start_date = parse_date_from_str(request.POST.get('sd')) end_date = parse_date_from_str(request.POST.get('ed')) target_address = request.POST.get('tg') extra_package = request.POST.get('ep') extra_days = request.POST.get('es') edit = request.POST.get('e') if not validate_empty_str(name): return render(request, 'errors/CustomError.html', {'error_message': _('please enter name')}) if not validate_empty_str(description): return render(request, 'errors/CustomError.html', {'error_message': _('please enter description')}) if not validate_empty_str(target_address): return render(request, 'errors/CustomError.html', {'error_message': _('please enter target address')}) if not validate_integer(extra_days): return render(request, 'errors/CustomError.html', {'error_message': _('please enter extra days for service')}) if not validate_integer(extra_package): return render(request, 'errors/CustomError.html', {'error_message': _('please enter extra package amount')}) if request.user.has_perm('CRM.change_polls'): if validate_integer(edit): if Polls.objects.filter(pk=edit).exists(): p = Polls.objects.get(pk=edit) else: p = Polls() else: p = Polls() else: p = Polls() p.name = name p.description = description p.end_date = end_date p.start_date = start_date p.extra_days = int(extra_days) p.extra_package = int(extra_package) p.target_address = target_address p.save() return redirect(reverse(view_polls)) else: return redirect(reverse(view_polls))
def send_text_message(user_id, text, is_password=False): if not validate_empty_str(text): return False if not validate_integer(user_id): return False text = text.encode('utf-8') username = read_config('sms_username') print username password = read_config('sms_password') line = read_config('sms_line') username_field = read_config('sms_username_field') password_field = read_config('sms_password_field') to_field = read_config('sms_target_field') text_field = read_config('sms_text_field') add_r = read_config('sms_url') line_field = read_config('sms_line_field') suc = read_config('sms_send_success') n = NotifyLog() try: # text = text.encode() user = UserProfile.objects.get(user=user_id) if not user.mobile: return False mobile = user.mobile if not add_r.lower().startswith('http://'): address = 'http://' + add_r + '?' else: address = add_r if validate_empty_str(line_field) and validate_empty_str(line): address = '{0}{1}={2}&'.format(address, line_field, line) if validate_empty_str(password_field) and validate_empty_str(password): address = '{0}{1}={2}&'.format(address, password_field, password) if validate_empty_str(username_field) and validate_empty_str(username): address = '{0}{1}={2}&'.format(address, username_field, username) if is_password: n.description = '***' else: n.description = text n.target = mobile n.notify_type = 1 n.is_read = True n.send_time = now() n.user = User.objects.get(pk=user_id) uc = urllib.urlencode({text_field: text}) address = '{0}{1}={2}&{3}'.format(address, to_field, mobile, uc) res = urlopen(address).read() res = str(res) if suc in res or suc == res: n.result = True else: n.result = False except Exception as e: print e.args[0] n.result = False finally: n.save() return n.result
def temp_charge_report(request): if request.method == 'GET': user = request.user granted = False if user.is_superuser or user.is_staff: granted = True sd = request.GET.get('sd') ed = request.GET.get('ed') if granted: ibs_id = request.GET.get('ib') user_id = request.GET.get('ui') rch = request.GET.get('rc') charges = FreeTrafficLog.objects.all() else: ibs_id = 'invalid' user_id = 'invalid' rch = 'invalid' charges = FreeTrafficLog.objects.filter(user=user.pk) if request.GET.get('a'): if validate_integer(ibs_id): charges = charges.filter( user__fk_ibs_user_info_user__ibs_uid=ibs_id) if validate_integer(user_id): charges = charges.filter(user=user_id) if validate_integer(rch): charges = charges.filter(recharger=rch) if validate_empty_str(sd): start_date = parse_date_from_str(sd) charges = charges.filter(datetime__gt=start_date) if validate_empty_str(ed): end_date = parse_date_from_str(ed) charges = charges.filter(datetime__lt=end_date) charges = charges.order_by('-datetime') res = init_pager(charges, 30, request.GET.get('nx'), 'charges', request=request) return render(request, 'finance/TempChargeReport.html', res) else: return render(request, 'errors/AccessDenied.html')
def create_service_by_group_name(group_name, create_service=False): # l = create_logger(None, "CREATE_IBS_GRP") if not validate_empty_str(group_name): return False try: ibs = IBSManager() g_info = ibs.get_group_details(group_name) if not g_info: return False gid = g_info['group_id'] res0 = build_traffic_by_group_credit(g_info) if res0 is False: # l.warning("Unable to find traffic for group : %s" % group_name) res0 = 100 if not IBSService.objects.filter(ibs_group_id=gid).exists(): # l.info("Create a new service in CRM") new_ibs_group = IBSService() new_ibs_group.ibs_group_id = int(gid) new_ibs_group.ibs_name = g_info['group_name'] # new_ibs_group.save() new_ibs_group.name = g_info['group_name'] new_ibs_group.save() new_service_property = ServiceProperty() new_service_property.initial_package = res0 new_service_property.name = _('data for ') + new_ibs_group.name new_service_property.bandwidth = 128 new_service_property.base_price = 99999999 new_service_property.period = 30 # l.info("Saving original data") new_service_property.save() default_pr = DefaultServiceProperty() default_pr.default = new_service_property default_pr.service = new_ibs_group default_pr.save() ibs_service_pr = IBSServiceProperties() ibs_service_pr.service = new_ibs_group ibs_service_pr.properties = new_service_property ibs_service_pr.save() # l.info("Service created : %s" % new_service_property.pk) return new_ibs_group.pk else: # l.info("Attempt to update service information") ibg = IBSService.objects.get(ibs_group_id=gid) ibg.ibs_name = g_info['group_name'] # l.info("Service data updated : %s" % ibg.pk) # print 'map updated!!!' return ibg.pk # return -1 except Exception as e: # if e.args: # l.debug(" ".join([str(a) for a in e.args])) # else: # l.debug(e.message) return False
def get_user_credit(self, username): if not validate_empty_str(username): return 0 try: info = self.get_user_info_by_username(username) if info is None: return -1 return info.values()[0]['basic_info']['credit'] except Exception as e: print e.message return 0
def get_user_id_by_username(self, username, remove_user_id=False): if not validate_empty_str(username): return -1 try: uid = self.get_user_info_by_username(username, remove_user_id) if uid is None: return False return uid.keys()[0] except Exception as e: print e.message return False
def add_new_user(self, username, password, credit): if not validate_empty_str(username): return False if not validate_empty_str(password): return False try: auth = self.auth_params auth['owner_name'] = read_config('ibs_username', 'CRM') auth['group_name'] = 'no_group' auth['credit_comment'] = 'test' auth['count'] = 1 auth['credit'] = credit auth['isp_name'] = read_config('ibs_isp', 'Main') uid = self.proxy.user.addNewUsers(auth) # log.info('User has been created via : {0}'.format(uid)) self.assign_username(username, password, str(uid[0])) return True except xmlrpclib.Fault as e: print e.faultString return False
def search_tower(get): if not isinstance(get, dict): return Tower.objects.none() uid = get.get('ib') name = get.get('n') description = get.get('d') address = get.get('ad') pk = get.get('pk') res = Tower.objects.filter(is_deleted=False) if validate_integer(pk): res = res.filter(pk=pk) if validate_integer(uid): res = res.filter( fk_user_tower_tower__user__fk_ibs_user_info_user__ibs_uid=uid) if validate_empty_str(name): res = res.filter(name__icontains=name) if validate_empty_str(description): res = res.filter(description__icontains=description) if validate_empty_str(address): res = res.filter(address__icontains=address) return res
def change_credit(self, credit_amount, username, replace_credit=False): if not validate_float(credit_amount): return False if not validate_empty_str(username): return False try: uid = self.get_user_id_by_username(username) if uid is -1: return False return self.change_credit_by_uid(credit_amount, uid, replace_credit) except xmlrpclib.Fault as e: print e.faultString return False
def set_expire_date(self, username, add_days, new_service=False): if not validate_empty_str(username): return False if not validate_integer(add_days): return False uid = self.get_user_id_by_username(username) if uid is None: return False try: return self.set_expire_date_by_uid(uid, add_days, new_service) except xmlrpclib.Fault as e: print e.faultString return False
def add_new_group(self, group_name, comment=''): if not validate_empty_str(group_name): # log.error('No group name has specified') raise InvalidSTR('add new group', 'IBS Management') try: # log.info('Attempt to create a new group : {0}'.format(group_name)) auth = self.auth_params auth['group_name'] = group_name auth['comment'] = comment self.proxy.group.addNewGroup(auth) return True except xmlrpclib.Fault as e: print e.faultString return False
def create_department(request): if request.method == 'GET': did = request.GET.get('d') try: groups = Group.objects.all() except Exception as e: print e.message return render(request, 'errors/ServerError.html') if validate_integer(did): try: department = HelpDepartment.objects.get(pk=did) return render(request, 'help_desk/CreateDepartment.html', { 'dep': department, 'groups': groups }) except Exception as e: print e.message return render(request, 'errors/ServerError.html') return render(request, 'help_desk/CreateDepartment.html', {'groups': groups}) elif request.method == 'POST': gid = request.POST.get('slGroups', 'Invalid') name = request.POST.get('txtName') d = request.POST.get('d') if not validate_integer(gid) or gid == '-1': return render(request, 'errors/CustomError.html', {'error_message': _('no group selected')}) if not validate_empty_str(name): return render(request, 'errors/CustomError.html', {'error_message': _('enter a name please')}) try: if validate_integer(d): h = HelpDepartment.objects.get(pk=d) else: h = HelpDepartment() h.group = Group.objects.get(pk=gid) h.department_name = name # insert_new_action_log(request, None, _('create or update help department') + ' :' + name) h.save() fire_event(3617, h, None, request.user.pk) return redirect(reverse(show_all_departments)) except DBRecordExist: return render(request, 'errors/CustomError.html', {'error_message': _('the department name is exist')}) except DBInsertException as e: print e.message return render(request, 'errors/ServerError.html')
def reset_first_login(self, username): if not validate_empty_str(username): return False uid = self.get_user_id_by_username(username) if uid is -1: return False auth = self.auth_params auth['attrs'] = {} auth['user_id'] = str(uid) auth['to_del_attrs'] = ['first_login'] try: self.proxy.user.updateUserAttrs(auth) return True except xmlrpclib.Fault as e: print e.faultString return False
def modify_bank_data(request): """ Modify banking data @param request: @return: @type request: django.core.handlers.wsgi.WSGIRequest """ try: if request.method == 'GET': # return render(request, 'errors/AccessDenied.html') bid = request.GET.get('b') if not validate_integer(bid): return redirect(reverse(bank_api_management)) if not Banks.objects.filter(pk=bid).exists(): return redirect(reverse(bank_api_management)) if not BankProperties.objects.filter(bank=bid).exists(): return redirect(reverse(bank_api_management)) bbp = BankProperties.objects.filter(bank=bid) return render(request, 'finance/BankPropertiesManagement.html', {'properties': bbp, 'bid': bid}) elif request.method == 'POST': bid = request.POST.get('bid') if not validate_integer(bid): return redirect(reverse(bank_api_management)) if not Banks.objects.filter(pk=bid).exists(): return redirect(reverse(bank_api_management)) if not BankProperties.objects.filter(bank=bid).exists(): return redirect(reverse(bank_api_management)) # properties_list = properties_name = BankProperties.objects.filter(bank=bid).values_list('name', flat=True) transaction.set_autocommit(False) for p in properties_name: value = request.POST.get(p) if not validate_empty_str(value): return render(request, 'errors/CustomError.html', {'error_message': _('all fields are needed!')}) bp = BankProperties.objects.get(bank=bid, name=p) bp.value = value bp.save() transaction.commit() transaction.set_autocommit(True) # fire_event(4764,) # send_to_dashboard(4764, request.user.pk) return redirect(reverse(bank_api_management)) except Exception as e: print e.message return render(request, 'errors/ServerError.html')
def search_telegram_users(get): if not isinstance(get, dict): return TelegramUser.objects.none() users = TelegramUser.objects.filter(is_deleted=False) ibs_id = get.get('ib') join_date_start = parse_date_from_str(get.get('sd')) join_date_end = parse_date_from_str(get.get('ed')) username = get.get('tu') if validate_integer(ibs_id): users = users.filter(user__fk_ibs_user_info_user__ibs_uid=ibs_id) if validate_empty_str(username): users = users.filter(username__iexact=username) if join_date_start: users = users.filter(register_date__gt=join_date_start.date()) if join_date_end: users = users.filter(register_date__lt=join_date_end.date()) return users
def user_completed_challenge(request): if request.method == 'GET': token = request.GET.get('tx') if not validate_empty_str(token): return HttpResponse('') if not UserPolls.objects.filter(user_token=token).exists(): return HttpResponse('') data = UserPolls.objects.get(user_token=token) if data.is_finished: return HttpResponse('') data.completion_date = datetime.today() data.is_finished = True data.save() user = User.objects.filter(pk=data.user_id) send_gift_for_users.delay(user, data.poll.extra_days, data.poll.extra_package) return HttpResponse('1') else: return HttpResponse('')
def get_user_info_by_username(self, username, remove_user_id=False): if not validate_empty_str(username): return None try: auth = self.auth_params auth['normal_username'] = username if remove_user_id: auth.pop('user_id') if 'user_id' in auth: auth['user_id'] = '%s' % auth['user_id'] res = self.proxy.user.getUserInfo(auth) return res except xmlrpclib.Fault as e: print e.faultString return None except Exception as e: print e.message return ''