Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates (Sourcery refactored) #529

Closed
wants to merge 1 commit into from
Closed

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Sep 19, 2023

Pull Request #528 refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the updates branch, then run:

git fetch origin sourcery/updates
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from spointu September 19, 2023 14:18
lines = []
for row in ret:
lines.append(row.toDict())

return lines
return [row.toDict() for row in ret]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function UpdatesDatabase.tests refactored with the following changes:

Comment on lines -101 to +104

result = session.execute(sql)
session.commit()
session.flush()
resultat = [x for x in result]

resultat = list(result)
print(resultat)
if len(resultat) == 0:
return -1
else:
return [x for x in result]
return -1 if not resultat else list(result)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function UpdatesDatabase.test_xmppmaster refactored with the following changes:

Comment on lines -127 to -132
black_list = { 'nb_element_total': 0,
'id' : [],
'updateid_or_kb' : [],
'title': [],
"severity" : []}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function UpdatesDatabase.get_black_list refactored with the following changes:

Comment on lines -199 to -205
grey_list={ 'nb_element_total': 0,
'updateid' : [],
'title' : [],
'kb' : [],
'valided' : [],
'severity': []}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function UpdatesDatabase.get_grey_list refactored with the following changes:

Comment on lines -265 to -270
white_list={ 'nb_element_total': 0,
'updateid' : [],
'title' : [],
'kb' : [],
"severity": []}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function UpdatesDatabase.get_white_list refactored with the following changes:

Comment on lines -476 to +471
else:
re = [y for y in [x for x in result]]
for arssyncthing in re:
self.update_ars_status(arssyncthing[4], "pausing")
re = list(list(result))
for arssyncthing in re:
self.update_ars_status(arssyncthing[4], "pausing")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.get_ars_for_pausing_syncthing refactored with the following changes:

Comment on lines -515 to +508
resultat = [x for x in result]
if not resultat:
return -1
else:
return resultat[0][0]
resultat = list(result)
return -1 if not resultat else resultat[0][0]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.search_partage_for_package refactored with the following changes:

Comment on lines -537 to +527
resultat = [x for x in result]
if len(resultat) == 0:
return -1
else:
return resultat[0][0]
resultat = list(result)
return -1 if not resultat else resultat[0][0]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.search_ars_cluster_for_package refactored with the following changes:

Comment on lines -559 to +545
resultat = [x for x in result]
resultat = list(result)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.search_ars_master_cluster_ refactored with the following changes:

Comment on lines -600 to +586
resultat = [x for x in result]
if resultat:
return True
else:
return False
return bool(resultat := list(result))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.ars_in_num_cluster refactored with the following changes:

Comment on lines -709 to +691
setvalues = "AND xmppmaster.syncthing_machine.progress in (%s)" % ",".join([str(x) for x in valuecount])
setvalues = f'AND xmppmaster.syncthing_machine.progress in ({",".join([str(x) for x in valuecount])})'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.stat_syncthing_distributon refactored with the following changes:

Comment on lines -747 to +729
re = [x for x in result]
re = list(result)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.stat_syncthing_transfert refactored with the following changes:

Comment on lines -782 to +764
return [x for x in result][0]
return list(result)[0]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.getnumcluster_for_ars refactored with the following changes:

Comment on lines -810 to +792
return [y for y in [x for x in result]]
return list(list(result))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.getCluster_deploy_syncthing refactored with the following changes:

Comment on lines -874 to +860
sql = sql +";"
sql = f"{sql};"
result = session.execute(sql)
session.commit()
session.flush()
return [x for x in result]
return list(result)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.getMachine_deploy_Syncthing refactored with the following changes:

Comment on lines -2179 to +2167
if query is not None:
user_list = [user[0] for user in query]
return user_list
else:
return []
return [user[0] for user in query] if query is not None else []
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.get_list_of_users_for_shared_qa refactored with the following changes:

Comment on lines -2304 to +2289
def __returntextisNone__(para, text = ""):
if para == None:
return text
else:
return para
def __returntextisNone__(self, text = ""):
return text if self is None else self
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.__returntextisNone__ refactored with the following changes:

Comment on lines -2322 to +2307
presence = session.query(Machines.id).\
filter( Machines.macaddress.like(macaddress+'%')).first()
presence = (
session.query(Machines.id)
.filter(Machines.macaddress.like(f'{macaddress}%'))
.first()
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.getIdMachineFromMacaddress refactored with the following changes:

Comment on lines -2333 to +2355
filter(Machines.macaddress.like(macaddress) ).first()
filter(Machines.macaddress.like(macaddress) ).first()
elif agenttype=="machine":
machine = session.query(Machines).\
filter(and_(Machines.macaddress.like(macaddress),
filter(and_(Machines.macaddress.like(macaddress),
Machines.agenttype.like("machine")) ).first()
elif agenttype=="relayserver":
machine = session.query(Machines).\
filter(and_(Machines.macaddress.like(macaddress),
filter(and_(Machines.macaddress.like(macaddress),
Machines.agenttype.like("relayserver")) ).first()
session.commit()
session.flush()
result = {}
if machine:
result = { "id" : machine.id,
"jid" : machine.jid,
"platform" : machine.platform,
"archi" : machine.archi,
"hostname" : machine.hostname,
"uuid_inventorymachine" : machine.uuid_inventorymachine,
"ip_xmpp" : machine.ip_xmpp,
"ippublic" : machine.ippublic,
"macaddress" : machine.macaddress,
"subnetxmpp" : machine.subnetxmpp,
"agenttype" : machine.agenttype,
"classutil" : machine.classutil,
"groupdeploy" : machine.groupdeploy,
"urlguacamole" : machine.urlguacamole,
"picklekeypublic" : machine.picklekeypublic,
'ad_ou_user': machine.ad_ou_user,
'ad_ou_machine': machine.ad_ou_machine,
'kiosk_presence': machine.kiosk_presence,
'lastuser': machine.lastuser,
'keysyncthing' : machine.keysyncthing,
'enabled' : machine.enabled,
'uuid_serial_machine' : machine.uuid_serial_machine}
return result
return (
{
"id": machine.id,
"jid": machine.jid,
"platform": machine.platform,
"archi": machine.archi,
"hostname": machine.hostname,
"uuid_inventorymachine": machine.uuid_inventorymachine,
"ip_xmpp": machine.ip_xmpp,
"ippublic": machine.ippublic,
"macaddress": machine.macaddress,
"subnetxmpp": machine.subnetxmpp,
"agenttype": machine.agenttype,
"classutil": machine.classutil,
"groupdeploy": machine.groupdeploy,
"urlguacamole": machine.urlguacamole,
"picklekeypublic": machine.picklekeypublic,
'ad_ou_user': machine.ad_ou_user,
'ad_ou_machine': machine.ad_ou_machine,
'kiosk_presence': machine.kiosk_presence,
'lastuser': machine.lastuser,
'keysyncthing': machine.keysyncthing,
'enabled': machine.enabled,
'uuid_serial_machine': machine.uuid_serial_machine,
}
if machine
else {}
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.getMachinefrommacadress refactored with the following changes:

Comment on lines -2375 to +2400
filter(Machines.uuid_serial_machine.like(uuid_serial_machine) ).first()
filter(Machines.uuid_serial_machine.like(uuid_serial_machine) ).first()
elif agenttype=="machine":
machine = session.query(Machines).\
filter(and_(Machines.uuid_serial_machine.like(uuid_serial_machine),
filter(and_(Machines.uuid_serial_machine.like(uuid_serial_machine),
Machines.agenttype.like("machine")) ).first()
elif agenttype=="relayserver":
machine = session.query(Machines).\
filter(and_(Machines.uuid_serial_machine.like(uuid_serial_machine),
filter(and_(Machines.uuid_serial_machine.like(uuid_serial_machine),
Machines.agenttype.like("relayserver")) ).first()
session.commit()
session.flush()
result = {}
if machine:
result = { "id" : machine.id,
"jid" : machine.jid,
"platform" : machine.platform,
"archi" : machine.archi,
"hostname" : machine.hostname,
"uuid_inventorymachine" : machine.uuid_inventorymachine,
"ip_xmpp" : machine.ip_xmpp,
"ippublic" : machine.ippublic,
"macaddress" : machine.macaddress,
"subnetxmpp" : machine.subnetxmpp,
"agenttype" : machine.agenttype,
"classutil" : machine.classutil,
"groupdeploy" : machine.groupdeploy,
"urlguacamole" : machine.urlguacamole,
"picklekeypublic" : machine.picklekeypublic,
'ad_ou_user': machine.ad_ou_user,
'ad_ou_machine': machine.ad_ou_machine,
'kiosk_presence': machine.kiosk_presence,
'lastuser': machine.lastuser,
'keysyncthing' : machine.keysyncthing,
'enabled' : machine.enabled,
'uuid_serial_machine' : machine.uuid_serial_machine}
return result
return (
{
"id": machine.id,
"jid": machine.jid,
"platform": machine.platform,
"archi": machine.archi,
"hostname": machine.hostname,
"uuid_inventorymachine": machine.uuid_inventorymachine,
"ip_xmpp": machine.ip_xmpp,
"ippublic": machine.ippublic,
"macaddress": machine.macaddress,
"subnetxmpp": machine.subnetxmpp,
"agenttype": machine.agenttype,
"classutil": machine.classutil,
"groupdeploy": machine.groupdeploy,
"urlguacamole": machine.urlguacamole,
"picklekeypublic": machine.picklekeypublic,
'ad_ou_user': machine.ad_ou_user,
'ad_ou_machine': machine.ad_ou_machine,
'kiosk_presence': machine.kiosk_presence,
'lastuser': machine.lastuser,
'keysyncthing': machine.keysyncthing,
'enabled': machine.enabled,
'uuid_serial_machine': machine.uuid_serial_machine,
}
if machine
else {}
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.getMachinefromuuidsetup refactored with the following changes:

Comment on lines -2624 to +2614
if ret[0] == 0 :
return False
return True
return ret[0] != 0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.is_jiduser_organization_ad refactored with the following changes:

Comment on lines -2629 to +2617
if uuid.strip().lower().startswith("uuid"):
return uuid[4:]
else:
return uuid
return uuid[4:] if uuid.strip().lower().startswith("uuid") else uuid
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.uuidtoid refactored with the following changes:

Comment on lines -2646 to +2631
if ret[0] == 0 :
return False
return True
return ret[0] != 0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.is_id_inventory_organization_ad refactored with the following changes:

Comment on lines -2665 to +2648
if ret[0] == 0 :
return False
return True
return ret[0] != 0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.is_id_inventory_jiduser_organization_ad refactored with the following changes:

Comment on lines -2676 to +2657
query = query.filter(Organization_ad.ouuser.like('%'+filt+'%'))
query = query.filter(Organization_ad.ouuser.like(f'%{filt}%'))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.getAllOUuser refactored with the following changes:

Comment on lines -3469 to +3451
logging.getLogger().error("We tried to stop the deploiement for the cmd %s. We did not find the uuid %s" % (cmdid , inventoryuuid))
logging.getLogger().error(
f"We tried to stop the deploiement for the cmd {cmdid}. We did not find the uuid {inventoryuuid}"
)
return machine

except MultipleResultsFound as e:
logging.getLogger().error(str(e))
logging.getLogger().error("When stopping the deploiement we detected several machines for the cmd %s and uuid %s " % (cmdid , inventoryuuid))
logging.getLogger().error(
f"When stopping the deploiement we detected several machines for the cmd {cmdid} and uuid {inventoryuuid} "
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.get_machine_stop_deploy refactored with the following changes:

Comment on lines -3514 to +3512
ret={}
ret['len']= len(machine)
ret = {'len': len(machine)}
arraylist = []
for t in machine:
obj={}
obj['title'] = t.title
obj['pathpackage'] = t.pathpackage
obj['jid_relay'] = t.jid_relay
obj['inventoryuuid'] = t.inventoryuuid
obj['jidmachine'] = t.jidmachine
obj['state'] = t.state
obj['sessionid']=t.sessionid
obj['start'] = t.start
obj['startcmd'] = t.startcmd
obj['endcmd'] = t.endcmd
obj['host'] = t.host
obj['user'] = t.user
obj['login'] = str(t.login)
obj['command'] = t.command
obj['group_uuid'] = t.group_uuid
obj['macadress'] = t.macadress
obj['syncthing'] = t.syncthing
obj = {
'title': t.title,
'pathpackage': t.pathpackage,
'jid_relay': t.jid_relay,
'inventoryuuid': t.inventoryuuid,
'jidmachine': t.jidmachine,
'state': t.state,
'sessionid': t.sessionid,
'start': t.start,
'startcmd': t.startcmd,
'endcmd': t.endcmd,
'host': t.host,
'user': t.user,
'login': str(t.login),
'command': t.command,
'group_uuid': t.group_uuid,
'macadress': t.macadress,
'syncthing': t.syncthing,
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.get_group_stop_deploy refactored with the following changes:

Comment on lines -3807 to -3809
start = int(start)
limit = int(limit)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.getdeployment_cmd_and_title refactored with the following changes:

Comment on lines 3830 to -3855

start = int(start)
limit = int(limit)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.getdeployment refactored with the following changes:

Comment on lines -3893 to +3892
filter(and_( Deploy.inventoryuuid == uuid, Deploy.command == command_id))
filter(and_( Deploy.inventoryuuid == uuid, Deploy.command == command_id))
#, Deploy.result .isnot(None)
#print relayserver
relayserver = relayserver.all()
session.commit()
session.flush()
ret={}
ret['len']= len(relayserver)
ret = {'len': len(relayserver)}
arraylist=[]
for t in relayserver:
obj={}
obj['pathpackage']=t.pathpackage
obj['jid_relay']=t.jid_relay
obj['inventoryuuid']=t.inventoryuuid
obj['jidmachine']=t.jidmachine
obj['state']=t.state
obj['sessionid']=t.sessionid
obj['start']=t.start
if t.result is None:
obj['result']=""
else:
obj['result']=t.result
obj['host']=t.host
obj['user']=t.user
obj['login']=str(t.login)
obj['command']=t.command
obj = {
'pathpackage': t.pathpackage,
'jid_relay': t.jid_relay,
'inventoryuuid': t.inventoryuuid,
'jidmachine': t.jidmachine,
'state': t.state,
'sessionid': t.sessionid,
'start': t.start,
'result': "" if t.result is None else t.result,
'host': t.host,
'user': t.user,
'login': str(t.login),
'command': t.command,
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function XmppMasterDatabase.getdeployfromcommandid refactored with the following changes:

Base automatically changed from updates to integration September 19, 2023 14:19
@sourcery-ai sourcery-ai bot closed this Sep 19, 2023
@sourcery-ai sourcery-ai bot deleted the sourcery/updates branch September 19, 2023 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants