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

Urbackup wva (Sourcery refactored) #579

Closed
wants to merge 1 commit into from

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Jan 10, 2024

Pull Request #548 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 urbackup-wva branch, then run:

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

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from neoclust January 10, 2024 15:19
Comment on lines -82 to +88

enable_client_database(clientid)

command = "(echo [parameters] & echo backup_enabled = 1 & echo client_id = "+str(clientid)+" & echo authkey = "+str(authkey)+" & echo backup_server = urbackup://"+str(urbackup_server)+" & echo backup_port = "+str(urbackup_port)+") > C:\progra~1\pulse\etc\updatebackupclient.ini"
command = (
f"(echo [parameters] & echo backup_enabled = 1 & echo client_id = {str(clientid)} & echo authkey = {str(authkey)} & echo backup_server = urbackup://{str(urbackup_server)} & echo backup_port = {str(urbackup_port)}"
+ ") > C:\progra~1\pulse\etc\updatebackupclient.ini"
)
Copy link
Author

Choose a reason for hiding this comment

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

Function enable_client refactored with the following changes:

Comment on lines -217 to +220
if session == "":
return "No DATA in session"

return session
return "No DATA in session" if session == "" else session
Copy link
Author

Choose a reason for hiding this comment

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

Function get_ses refactored with the following changes:

if "content" in logs:
return logs["content"]

return "No DATA in logs"
return logs["content"] if "content" in logs else "No DATA in logs"
Copy link
Author

Choose a reason for hiding this comment

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

Function get_logs refactored with the following changes:

Comment on lines -271 to +268
if "content" in stats:
return stats["content"]

return "No DATA in stats"
return stats["content"] if "content" in stats else "No DATA in stats"
Copy link
Author

Choose a reason for hiding this comment

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

Function get_stats refactored with the following changes:

Comment on lines -289 to +283
if "content" in newgroup:
return newgroup["content"]

return "No DATA in newclient"
return newgroup["content"] if "content" in newgroup else "No DATA in newclient"
Copy link
Author

Choose a reason for hiding this comment

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

Function add_group refactored with the following changes:

for i in range(NB_DB_CONN_TRY):
for _ in range(NB_DB_CONN_TRY):
Copy link
Author

Choose a reason for hiding this comment

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

Function UrbackupDatabase.getDbConnection refactored with the following changes:

Comment on lines -73 to +83
sql="""SELECT * FROM urbackup.client_state WHERE client_id = '%s';"""%(client_id)
sql = f"""SELECT * FROM urbackup.client_state WHERE client_id = '{client_id}';"""

resultquery = session.execute(sql)
session.commit()
session.flush()

result = [{column: value for column,
value in rowproxy.items()}
for rowproxy in resultquery]


result = [dict(rowproxy.items()) for rowproxy in resultquery]

except Exception as e:
logging.getLogger().error(str(e))

Copy link
Author

Choose a reason for hiding this comment

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

Function UrbackupDatabase.getClientStatus refactored with the following changes:

Comment on lines -91 to +99
sql="""UPDATE client_state SET state = '%s' WHERE client_id = '%s';"""%(state, client_id)
sql = f"""UPDATE client_state SET state = '{state}' WHERE client_id = '{client_id}';"""

session.execute(sql)
session.commit()
session.flush()

return True

except Exception as e:
logging.getLogger().error(str(e))

Copy link
Author

Choose a reason for hiding this comment

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

Function UrbackupDatabase.editClientState refactored with the following changes:

Comment on lines -107 to +115
sql="""INSERT INTO client_state VALUES ('%s', '1', '%s');"""%(client_id, authkey)
sql = f"""INSERT INTO client_state VALUES ('{client_id}', '1', '{authkey}');"""

session.execute(sql)
session.commit()
session.flush()

return True

except Exception as e:
logging.getLogger().error(str(e))

Copy link
Author

Choose a reason for hiding this comment

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

Function UrbackupDatabase.insertNewClient refactored with the following changes:

Comment on lines -123 to +131
sql="""SELECT id, jid, enabled FROM xmppmaster.machines WHERE jid = '%s';"""%(jid)
sql = f"""SELECT id, jid, enabled FROM xmppmaster.machines WHERE jid = '{jid}';"""

resultquery = session.execute(sql)
session.commit()
session.flush()

result = [{column: value for column,
value in rowproxy.items()}
for rowproxy in resultquery]


result = [dict(rowproxy.items()) for rowproxy in resultquery]

except Exception as e:
logging.getLogger().error(str(e))

Copy link
Author

Choose a reason for hiding this comment

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

Function UrbackupDatabase.getComputersEnableValue refactored with the following changes:

@neoclust neoclust closed this Jan 15, 2024
@neoclust neoclust deleted the sourcery/urbackup-wva branch April 10, 2024 12:14
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.

None yet

1 participant