Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _fake_msg_dialog_exec_overwrite(self):
self.dialog._msg_box.show()
QTest.qWaitForWindowActive(self.dialog._msg_box)
_click_area(self.dialog._msg_box_button_overwrite)
return QMessageBox.Accepted
def confirm_dialog(self):
"""
Show the confirmation dialog with the proper message in case
```showConfirmMessage``` is True.
Returns
-------
bool
True if the message was confirmed or if ```showCofirmMessage```
is False.
"""
if self._show_confirm_dialog:
if self._confirm_message == "":
self._confirm_message = PyDMPushButton.DEFAULT_CONFIRM_MESSAGE
msg = QMessageBox()
msg.setIcon(QMessageBox.Question)
msg.setText(self._confirm_message)
msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
msg.setDefaultButton(QMessageBox.No)
ret = msg.exec_()
if ret == QMessageBox.No:
return False
return True
def del_rule(self):
"""Delete the rule selected in the rules list."""
idx = self.get_current_index()
if idx < 0:
return
name = self.lst_rule_item.text()
confirm_message = "Are you sure you want to delete Rule: {}?".format(
name)
reply = QtWidgets.QMessageBox().question(self, 'Message',
confirm_message,
QtWidgets.QMessageBox.Yes,
QtWidgets.QMessageBox.No)
if reply == QtWidgets.QMessageBox.Yes:
self.lst_rules.takeItem(idx)
self.lst_rules.clearSelection()
self.rules.pop(idx)
self.clear_form()
def _confirm_close(self):
"""Ask for close confirmation
:rtype: bool. True if user wishes to close. False otherwise
"""
if self._warn_close and not os.environ.get('GLUE_TESTING'):
buttons = QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel
dialog = QtWidgets.QMessageBox.warning(self, "Confirm Close",
"Do you want to close this window?",
buttons=buttons,
defaultButton=QtWidgets.QMessageBox.Cancel)
return dialog == QtWidgets.QMessageBox.Ok
return True
args = ["-c", "import sys; print(sys.version_info[0])"]
proc = programs.run_program(pyexec, args)
console_version = int(proc.communicate()[0])
except IOError:
console_version = spyder_version
except ValueError:
return False
if spyder_version != console_version:
QMessageBox.warning(self, _('Warning'),
_("You selected a <b>Python %d</b> interpreter for the console "
"but Spyder is running on <b>Python %d</b>!.<br><br>"
"Although this is possible, we recommend you to install and "
"run Spyder directly with your selected interpreter, to avoid "
"seeing false warnings and errors due to the incompatible "
"syntax between these two Python versions."
) % (console_version, spyder_version), QMessageBox.Ok)
return True
"this command will remove all your Spyder configuration files "
"located in '%s').<br><br>"
"If restoring the default settings does not help, please take "
"the time to search for <a href="\"%s\"">known bugs</a> or "
"<a href="\"%s\"">discussions</a> matching your situation before "
"eventually creating a new issue <a href="\"%s\"">here</a>. "
"Your feedback will always be greatly appreciated."
"" % (get_conf_path(), __project_url__,
__forum_url__, __project_url__))
# Create main window
mainwindow = None
try:
mainwindow = run_spyder(app, options, args)
except FontError as fontError:
QMessageBox.information(None, "Spyder",
"Spyder was unable to load the <i>Spyder 3</i> "
"icon theme. That's why it's going to fallback to the "
"theme used in Spyder 2.<br><br>"
"For that, please close this window and start Spyder again.")
CONF.set('main', 'icon_theme', 'spyder 2')
except BaseException:
CONF.set('main', 'crash', True)
import traceback
traceback.print_exc(file=STDERR)
traceback.print_exc(file=open('spyder_crash.log', 'w'))
if mainwindow is None:
# An exception occured
if SPLASH is not None:
SPLASH.hide()
return
def _offer_overwriting_gui():
"""
Offers up a overwriting QMessageBox giving the option to overwrite a project, and returns the reply.
:return: QMessaageBox.Yes or QMessageBox.No or QMessageBox.Cancel; The value is the value selected by the user.
"""
return QMessageBox().question(None, "Overwrite project?",
"Would you like to overwrite the selected project?",
QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel,
QMessageBox.Yes)
def shutdown_kernel(self):
"""Shutdown the kernel of the client."""
kernel_id = self.get_kernel_id()
if kernel_id:
delete_url = self.add_token(url_path_join(self.server_url,
'api/kernels/',
kernel_id))
delete_req = requests.delete(delete_url)
if delete_req.status_code != 204:
QMessageBox.warning(
self,
_("Server error"),
_("The Jupyter Notebook server "
"failed to shutdown the kernel "
if sys.__stdout__ is None:
sys.__stdout__ = sys.stdout
stdout_set = True
try:
ic.main(['--no-deps', '-I', branch])
ic.main([branch])
finally:
if stdout_set:
sys.__stdout__ = None # Let's leave things as we found them.
(pip.download.DownloadProgressBar,
pip.download.DownloadProgressSpinner) = old_classes
else:
try:
branch.checkout()
except git.GitCommandError as e:
mb = QMessageBox(QMessageBox.Critical, tr("Git checkout failed"),
e.stderr)
mb.exec_()
raise ValueError()
def instrument_changed_warning(self):
msg = QtWidgets.QMessageBox(self)
msg.setIcon(QtWidgets.QMessageBox.Warning)
msg.setText("Changing instrument will reset the interface, continue?")
msg.setWindowTitle("Changing Instrument")
msg.setStandardButtons(
QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel)
retval = msg.exec_()
if retval == 1024:
# The "OK" code
return 1
else:
return 0