Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _get_or_start_maestral_daemon(self):
pid = get_maestral_pid(CONFIG_NAME)
if pid:
self._started = False
else:
if IS_MACOS_BUNDLE:
res = start_maestral_daemon_thread(CONFIG_NAME)
else:
res = start_maestral_daemon_process(CONFIG_NAME)
if res is False:
error_dialog = UserDialog(
"Could not start Maestral",
"Could not start or connect to sync daemon. Please try again and " +
"contact the developer if this issue persists."
)
error_dialog.exec_()
self.quit()
else:
self._started = True
return get_maestral_daemon_proxy(CONFIG_NAME)
def _notify_updates_user_requested(self, res):
if res["error"]:
update_dialog = UserDialog("Could not check for updates", res["error"])
update_dialog.exec_()
elif res["update_available"]:
self._show_update_dialog(res)
elif not res["update_available"]:
message = 'Maestral v{} is the newest version available.'.format(res["latest_release"])
update_dialog = UserDialog("You’re up-to-date!", message)
update_dialog.exec_()
msg_box.setAcceptButtonName("Keep")
msg_box.addSecondAcceptButton("Replace", icon="edit-clear")
msg_box.addCancelButton()
res = msg_box.exec_()
if res == 1:
pass
elif res == 2:
shutil.rmtree(dropbox_path, ignore_errors=True)
else:
return
elif osp.isfile(dropbox_path):
msg = ('There already is a file named "{0}" at this location. Would '
'you like to replace it?'.format(self.mdbx.get_conf("main", "default_dir_name")))
msg_box = UserDialog("File conflict", msg, parent=self)
msg_box.setAcceptButtonName("Replace")
msg_box.addCancelButton()
res = msg_box.exec_()
if res == 0:
return
else:
delete_file_or_folder(dropbox_path)
self.mdbx.create_dropbox_directory(path=dropbox_path, overwrite=False)
# switch to next page
self.mdbx.set_conf("main", "excluded_folders", [])
self.stackedWidget.slideInIdx(3)
self.treeViewFolders.setFocus()
def _show_update_dialog(res):
url_r = "https://github.com/samschott/maestral-dropbox/releases"
message = (
'Maestral v{0} is available. Please use your package manager to '
'update Maestral or go to the <a href="\"{1}\""><span>releases</span></a> '
'page to download the new version. '
'<div style="height:5px;font-size:5px;"> <br></div>'
'<b>Release notes:</b>'
).format(res["latest_release"], url_r)
list_style = '<ul style="margin-top: 0px; margin-bottom: 0px; margin-left: -20px; ' \
'margin-right: 0px; -qt-list-indent: 1;">'
styled_release_notes = res["release_notes"].replace('<ul>', list_style)
update_dialog = UserDialog("Update available", message, styled_release_notes)
update_dialog.exec_()
update_dialog.deleteLater()
</ul></ul>
def _stop_and_exec_error_dialog(self, title, message, exc_info=None):
self.setIcon(SYNC_ERROR)
if self.mdbx:
self.mdbx.stop_sync()
if self.pauseAction:
self.pauseAction.setText("Start Syncing")
error_dialog = UserDialog(title, message, exc_info)
error_dialog.exec_()
def _notify_updates_user_requested(self, res):
if res["error"]:
update_dialog = UserDialog("Could not check for updates", res["error"])
update_dialog.exec_()
elif res["update_available"]:
self._show_update_dialog(res)
elif not res["update_available"]:
message = 'Maestral v{} is the newest version available.'.format(res["latest_release"])
update_dialog = UserDialog("You’re up-to-date!", message)
update_dialog.exec_()
def on_auth_clicked(self):
if self.lineEditAuthCode.text() == "":
msg = "Please enter an authentication token."
msg_box = UserDialog("Authentication failed.", msg, parent=self)
msg_box.open()
else:
self.progressIndicator.startAnimation()
self.pushButtonAuthPageLink.setEnabled(False)
self.lineEditAuthCode.setEnabled(False)
self.verify_token_async()