mirror of
https://github.com/ComputerScienceHouse/proxstar.git
synced 2025-02-14 14:01:51 +00:00
Fixing black and pylint
This commit is contained in:
parent
d660549200
commit
62490d6858
6 changed files with 23 additions and 18 deletions
|
@ -21,7 +21,12 @@ disable =
|
|||
wrong-import-position,
|
||||
logging-format-interpolation,
|
||||
bare-except,
|
||||
too-many-public-methods
|
||||
too-many-public-methods,
|
||||
consider-using-with,
|
||||
consider-using-f-string,
|
||||
unspecified-encoding,
|
||||
consider-iterating-dictionary,
|
||||
inconsistent-return-statements
|
||||
|
||||
[REPORTS]
|
||||
output-format = text
|
||||
|
|
|
@ -301,7 +301,7 @@ def vm_cpu(vmid, cores):
|
|||
vm = VM(vmid)
|
||||
cur_cores = vm.cpu
|
||||
if cores >= cur_cores:
|
||||
if vm.qmpstatus == 'running' or vm.qmpstatus == 'paused':
|
||||
if vm.qmpstatus in ('running', 'paused'):
|
||||
usage_check = user.check_usage(cores - cur_cores, 0, 0)
|
||||
else:
|
||||
usage_check = user.check_usage(cores, 0, 0)
|
||||
|
@ -322,7 +322,7 @@ def vm_mem(vmid, mem):
|
|||
vm = VM(vmid)
|
||||
cur_mem = vm.mem // 1024
|
||||
if mem >= cur_mem:
|
||||
if vm.qmpstatus == 'running' or vm.qmpstatus == 'paused':
|
||||
if vm.qmpstatus in ('running', 'paused'):
|
||||
usage_check = user.check_usage(0, mem - cur_mem, 0)
|
||||
else:
|
||||
usage_check = user.check_usage(0, mem, 0)
|
||||
|
|
|
@ -58,7 +58,7 @@ def get_expiring_vms(db):
|
|||
|
||||
|
||||
def get_user_usage_limits(db, user):
|
||||
limits = dict()
|
||||
limits = {}
|
||||
if is_rtp(user):
|
||||
limits['cpu'] = 1000
|
||||
limits['mem'] = 1000
|
||||
|
@ -113,7 +113,7 @@ def get_pool_cache(db):
|
|||
db_pools = db.query(Pool_Cache).all()
|
||||
pools = []
|
||||
for pool in db_pools:
|
||||
pool_dict = dict()
|
||||
pool_dict = {}
|
||||
pool_dict['user'] = pool.pool
|
||||
pool_dict['vms'] = pool.vms
|
||||
pool_dict['num_vms'] = pool.num_vms
|
||||
|
@ -149,7 +149,7 @@ def add_ignored_pool(db, pool):
|
|||
def get_templates(db):
|
||||
templates = []
|
||||
for template in db.query(Template).all():
|
||||
template_dict = dict()
|
||||
template_dict = {}
|
||||
template_dict['id'] = template.id
|
||||
template_dict['name'] = template.name
|
||||
template_dict['disk'] = template.disk
|
||||
|
@ -158,7 +158,7 @@ def get_templates(db):
|
|||
|
||||
|
||||
def get_template(db, template_id):
|
||||
template_dict = dict()
|
||||
template_dict = {}
|
||||
if db.query(exists().where(Template.id == template_id)).scalar():
|
||||
template = db.query(Template).filter(Template.id == template_id).one()
|
||||
template_dict['id'] = template.id
|
||||
|
|
|
@ -50,8 +50,8 @@ class User:
|
|||
for job in jobs:
|
||||
job = q.fetch_job(job)
|
||||
if job and len(job.args) > 2:
|
||||
if job.args[0] == self.name or job.args[2] == self.name:
|
||||
vm_dict = dict()
|
||||
if self.name in (job.args[0], job.args[2]):
|
||||
vm_dict = {}
|
||||
vm_dict['name'] = job.args[1]
|
||||
vm_dict['status'] = job.meta.get('status', 'no status yet')
|
||||
vm_dict['pending'] = True
|
||||
|
@ -67,7 +67,7 @@ class User:
|
|||
|
||||
@lazy_property
|
||||
def usage(self):
|
||||
usage = dict()
|
||||
usage = {}
|
||||
usage['cpu'] = 0
|
||||
usage['mem'] = 0
|
||||
usage['disk'] = 0
|
||||
|
@ -77,7 +77,7 @@ class User:
|
|||
for vm in vms:
|
||||
if 'status' in vm:
|
||||
vm = VM(vm['vmid'])
|
||||
if vm.status == 'running' or vm.status == 'paused':
|
||||
if vm.status in ('running', 'paused'):
|
||||
usage['cpu'] += int(vm.cpu)
|
||||
usage['mem'] += int(vm.mem) / 1024
|
||||
for disk in vm.disks:
|
||||
|
@ -86,11 +86,11 @@ class User:
|
|||
|
||||
@lazy_property
|
||||
def usage_percent(self):
|
||||
percents = dict()
|
||||
percents = {}
|
||||
percents['cpu'] = round(self.usage['cpu'] / self.limits['cpu'] * 100)
|
||||
percents['mem'] = round(self.usage['mem'] / self.limits['mem'] * 100)
|
||||
percents['disk'] = round(self.usage['disk'] / self.limits['disk'] * 100)
|
||||
for resource in percents:
|
||||
for resource in percents.items():
|
||||
if percents[resource] > 100:
|
||||
percents[resource] = 100
|
||||
return percents
|
||||
|
@ -121,7 +121,7 @@ def get_vms_for_rtp(proxmox, database):
|
|||
pools = []
|
||||
for pool in get_pools(proxmox, database):
|
||||
user = User(pool)
|
||||
pool_dict = dict()
|
||||
pool_dict = {}
|
||||
pool_dict['user'] = user.name
|
||||
pool_dict['vms'] = user.vms
|
||||
pool_dict['num_vms'] = len(pool_dict['vms'])
|
||||
|
|
|
@ -28,7 +28,7 @@ def get_vnc_targets():
|
|||
if os.path.exists(app.config['WEBSOCKIFY_TARGET_FILE']):
|
||||
target_file = open(app.config['WEBSOCKIFY_TARGET_FILE'])
|
||||
for line in target_file:
|
||||
target_dict = dict()
|
||||
target_dict = {}
|
||||
values = line.strip().split(':')
|
||||
target_dict['token'] = values[0]
|
||||
target_dict['port'] = values[2]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
black~=20.8b1
|
||||
black~=22.3.0
|
||||
csh-ldap~=2.2.0
|
||||
flask==1.1.2
|
||||
jinja2==2.11.3
|
||||
|
@ -7,7 +7,7 @@ gunicorn==20.0.4
|
|||
paramiko==2.7.2
|
||||
proxmoxer==1.1.1
|
||||
psutil==5.8.0
|
||||
psycopg2-binary==2.8.6
|
||||
psycopg2-binary==2.9.3
|
||||
python-dateutil==2.8.1
|
||||
redis==3.5.3
|
||||
requests==2.25.1
|
||||
|
@ -18,7 +18,7 @@ sqlalchemy==1.3.22
|
|||
sshtunnel==0.2.2
|
||||
tenacity==5.0.2
|
||||
websockify==0.9.0
|
||||
pylint==2.6.0
|
||||
pylint==2.13.9
|
||||
pylint-quotes==0.2.1
|
||||
sentry-sdk[flask]
|
||||
sentry-sdk~=0.19.5
|
||||
|
|
Loading…
Reference in a new issue