def get(self, request, *args, **kwargs): response = BaseResponse() ret = {} file = request.GET.get('file', None) business_id = request.GET.get('business_id', None) print(file, business_id) if file and business_id: business_obj = models.BusinessTwo.objects.filter( id=business_id).first() business_name = business_obj.name file_path = '%sprod/%s/%s' % (jenkins_config.config_path, business_name, file) try: with open(file_path, "r") as f: response.data = f.read() f.close() response.status = True except Exception as e: with open(file_path, "r", encoding='gb2312') as f: response.data = f.read() f.close() response.status = True return JsonResponse(response.__dict__) business = request.GET.get('business', None) if business: business_obj = models.BusinessTwo.objects.filter( id=business).first() business_name = business_obj.name config_path = '%sprod/%s/' % (jenkins_config.config_path, business_name) if os.path.exists(config_path): files = os.listdir(config_path) response.data = files response.status = True else: response.status = False return JsonResponse(response.__dict__) business_two_list = models.BusinessTwo.objects.all() ret['menu'] = menu(request) response.data = ret return render(request, 'configs.html', { 'business_two_list': business_two_list, 'response': response })
def get(self, request, nid): response = BaseResponse() asset_obj = models.ReleaseTask.objects.filter(id=nid).first() response.data = asset_obj # device_type_id = asset_obj.host_type # response = asset.Asset.assets_detail(nid, device_type_id) ret = {} values = models.AuditLog.objects.filter(audit_id=nid).only('audit_time', 'audit_msg') result = map(lambda x: {'time': x.audit_time, 'msg': "%s" % x.audit_msg}, values) result = list(result) ret['data_list'] = result ret['menu'] = menu(request) print(ret) response.status = True return render(request, 'release_detail.html', {'response': response, 'log': ret})
def main(): read_conf() if len(sys_argv) == 3: hostname = sys_argv[1] port = int(sys_argv[2]) else: hostname = CONF_DICT['hostname'] strport = CONF_DICT['port'] port = int(strport) output = '' if CONF_DICT['output'] != 'console': output = join(str(Path.home()), CONF_DIR_NAME, LOG_FILE_NAME) listener = ConsoleListener(output) db_file = join(str(Path.home()), CONF_DIR_NAME, DB_FILE_NAME) server = serv.Server(hostname, port, listener, db_file) server.run() while True: if CONF_DICT['output'] == 'console': menu_item = menu.menu(menu.SERVER_MAIN_MENU) if menu_item == 'q': server.stop_server() print('Good buy!') break elif menu_item == '1': for record in server.log: print(record) elif menu_item == '2': for record in server.users: print(record) elif menu_item == '3': for record in server.connected: print(record) elif menu_item == '4': session = server.db.Session() postponed_list = session.query(PostponedMessages).all() for record in postponed_list: print(record.user, record.message) session.close() elif menu_item == '5': for record in server.clients: print(record)
def fetch_assets(self, request): response = BaseResponse() try: ret = {} conditions = self.assets_condition(request) asset_count = models.Asset.objects.filter(conditions).count() page_info = PageInfo(request.GET.get('pager', None), asset_count) asset_list = models.Asset.objects.filter(conditions).extra( select=self.extra_select).values( *self.values_list)[page_info.start:page_info.end] ret['table_config'] = self.table_config ret['condition_config'] = self.condition_config ret['data_list'] = list(asset_list) ret['page_info'] = { "page_str": page_info.pager(), "page_start": page_info.start, } business_1_lists = self.business_1_list(request) business_2_lists = self.business_2_list(request) business_3_lists = self.business_3_list(request) ret['global_dict'] = { 'device_status_list': self.device_status_list, 'device_type_list': self.device_type_list, 'idc_list': self.idc_list, 'business_unit_list': self.business_unit_list, 'business_1_list': business_1_lists, 'business_2_list': business_2_lists, 'business_3_list': business_3_lists } # ret['menu'] = '''<a id="menu_create" class="menu-item" href="/_project.html"><i class="fa fa-gitlab" # aria-hidden="true" style="width: 14px; margin-left: 1px"></i><span>项目创建</span></a> # ''' ret['menu'] = menu(request) print('-----', ret['menu']) response.data = ret response.message = '获取成功' except Exception as e: response.status = False response.message = str(e) return response
def fetch_assets(self, request): response = BaseResponse() try: ret = {} conditions = self.assets_condition(request) asset_count = models.ProjectTask.objects.filter(conditions).count() page_info = PageInfo(request.GET.get('pager', None), asset_count) asset_list = models.ProjectTask.objects.filter(conditions).extra( select=self.extra_select).values( *self.values_list)[page_info.start:page_info.end] ret['table_config'] = self.table_config ret['condition_config'] = self.condition_config ret['data_list'] = list(asset_list) ret['page_info'] = { "page_str": page_info.pager(), "page_start": page_info.start, } business_1_lists = self.business_1_list(request) business_2_lists = self.business_2_list(request) business_3_lists = self.business_3_list(request) ret['global_dict'] = { 'device_status_list': self.device_status_list, 'device_type_list': self.device_type_list, 'jdk_version_list': self.jdk_version_list, 'static_type_list': self.static_type_list, 'idc_list': self.idc_list, 'business_unit_list': self.business_unit_list, 'business_1_list': business_1_lists, 'business_2_list': business_2_lists, 'business_3_list': business_3_lists } ret['menu'] = menu(request) response.data = ret response.message = '获取成功' except Exception as e: response.status = False response.message = str(e) return response
def fetch_assets(self, request): response = BaseResponse() username = request.GET.get('username') try: ret = {} # conditions = self.assets_condition(request) asset_count = models.AuthInfo.objects.filter( username=username).count() page_info = PageInfo(request.GET.get('pager', None), asset_count) asset_list = models.AuthInfo.objects.filter( username=username).extra(select=self.extra_select).values( *self.values_list)[page_info.start:page_info.end] ret['table_config'] = self.table_config ret['condition_config'] = self.condition_config ret['data_list'] = list(asset_list) ret['page_info'] = { "page_str": page_info.pager(), "page_start": page_info.start, } ret['global_dict'] = { 'device_status_list': self.device_status_list, 'rank_list': self.rank_list, 'idc_list': self.idc_list, 'business_unit_list': self.business_unit_list, 'business_1_list': self.business_1_list, 'business_2_list': self.business_2_list, 'business_3_list': self.business_3_list } ret['menu'] = menu(request) response.data = ret response.message = '获取成功' except Exception as e: response.status = False response.message = str(e) return response
# Screen Screen_class = Screen(background=f"{current_dir}/img/bg/bg2.jpg", dimension=(500, 700)) screen = Screen_class.screen # fonts text_size = 30 myfont = pygame.font.Font(None, text_size) ### Menu # 1) menu perso perso = menu(screen, [Personnage(name) for name in Alien_list.keys()]) print(perso) # 2) menu weapons weapon_model = menu_weapon(screen, [Weapons_list[model] for model in Weapons_list.keys()]) ###### # Players ex:(galas0) # CHOOSE Player_class = Personnage(perso) player = Player_class.small_image # ##
def get(self, request, *args, **kwargs): response = BaseResponse() # 由于读取的配置文件夹不在本地 所以要先同步过来 local_path = '/opt/%s' % os.path.basename(config_config.config_path) if os.path.exists(local_path): cmd = 'rm -fr %s' % local_path print(cmd) os.system(cmd) try: cmd = 'scp -r root@%s:%s /opt/' % (config_config.config_in_host_ip, config_config.config_path) os.system(cmd) except Exception as e: response.status = False response.message = '读取配置文件%s:%s失败..%s' % (config_config.config_in_host_ip, config_config.config_path, e) return JsonResponse(response.__dict__) json_data = [] config_localhost_path = '/opt/%s' % os.path.basename(config_config.config_path) json_data = self.load_path(config_localhost_path, json_data) response.data = json_data response.status = True return JsonResponse(response.__dict__) ret = {} file = request.GET.get('file', None) business_id = request.GET.get('business_id', None) print(file, business_id) if file and business_id: business_obj = models.BusinessTwo.objects.filter(id=business_id).first() business_name = business_obj.name file_path = '%sprod/%s/%s' % (jenkins_config.config_path, business_name, file) try: with open(file_path, "r") as f: response.data = f.read() f.close() response.status = True except Exception as e: with open(file_path, "r", encoding='gb2312') as f: response.data = f.read() f.close() response.status = True return JsonResponse(response.__dict__) business = request.GET.get('business', None) if business: business_obj = models.BusinessTwo.objects.filter(id=business).first() business_name = business_obj.name config_path = '%sprod/%s/' % (jenkins_config.config_path, business_name) if os.path.exists(config_path): files = os.listdir(config_path) response.data = files response.status = True else: response.status = False return JsonResponse(response.__dict__) business_two_list = models.BusinessTwo.objects.all() ret['menu'] = menu(request) response.data = ret return render(request, 'configs.html', {'business_two_list': business_two_list, 'response': response})