本文整理汇总了Python中btsyncutils.BtBaseDialog.run方法的典型用法代码示例。如果您正苦于以下问题:Python BtBaseDialog.run方法的具体用法?Python BtBaseDialog.run怎么用?Python BtBaseDialog.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类btsyncutils.BtBaseDialog
的用法示例。
在下文中一共展示了BtBaseDialog.run方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from btsyncutils import BtBaseDialog [as 别名]
# 或者: from btsyncutils.BtBaseDialog import run [as 别名]
def run(self):
while True:
response = BtBaseDialog.run(self)
if response == Gtk.ResponseType.CANCEL:
return response
elif response == Gtk.ResponseType.OK:
self.secret = self.secret_w.get_text()
self.folder = self.folder_w.get_text()
# test if secret is OK
if self.api.get_error_code(self.api.get_secrets(self.secret)) > 0:
self.show_warning(
'This secret is invalid.\nPlease generate a new '\
'secret or enter your shared folder secret.'
)
# test if string is an absolute path and a directory
elif len(self.folder) == 0 or self.folder[0] != '/' or not os.path.isdir(self.folder):
self.show_warning('Can\'t open the destination folder.')
# test if the specified directory is readable and writable
elif not os.access(self.folder,os.W_OK) or not os.access(self.folder,os.R_OK):
self.show_warning(
'Don\'t have permissions to write to the selected folder.'
)
# test if the specified data is unique
elif self.is_duplicate_folder(self.folder,self.secret):
self.show_warning('Selected folder is already added to BitTorrent Sync.')
else:
return response
示例2: run
# 需要导入模块: from btsyncutils import BtBaseDialog [as 别名]
# 或者: from btsyncutils.BtBaseDialog import run [as 别名]
def run(self):
self.dlg.set_default_response(Gtk.ResponseType.OK)
while True:
response = BtBaseDialog.run(self)
if response == Gtk.ResponseType.CANCEL:
return response
elif response == Gtk.ResponseType.DELETE_EVENT:
return response
elif response == Gtk.ResponseType.OK:
if self.changed:
# read settings
self.username = self.username_w.get_text()
self.password = self.password_w.get_text()
if self.username == '' or self.password == '':
self.username = None
self.password = None
self.portui = self.bindport_w.get_value_as_int() if self.bindportset_w.get_active() else None
if self.bindlocal_w.get_active():
self.bindui = None
elif self.bindall_w.get_active():
self.bindui = '0.0.0.0'
# process settings
self.agent.set_pref('username', self.username, delnone=True)
self.agent.set_pref('password', self.password, delnone=True)
self.agent.set_pref('bindui', self.bindui, delnone=True)
self.agent.set_pref('portui', self.portui, delnone=True)
# restart the whole game...
if self.agent.paused:
self.agent.load_prefs()
self.agent.read_prefs()
self.agent.reset_connection_params()
else:
self.agent.suspend()
self.agent.load_prefs()
self.agent.read_prefs()
self.agent.reset_connection_params()
self.agent.resume()
return response
示例3: run
# 需要导入模块: from btsyncutils import BtBaseDialog [as 别名]
# 或者: from btsyncutils.BtBaseDialog import run [as 别名]
def run(self):
self.dlg.set_default_response(Gtk.ResponseType.OK)
while True:
response = BtBaseDialog.run(self)
if response == Gtk.ResponseType.CANCEL:
return response
elif response == Gtk.ResponseType.DELETE_EVENT:
return response
elif response == Gtk.ResponseType.OK:
self.addr = self.addr_w.get_text()
self.port = self.port_w.get_text()
# test if a hostname is specified
if len(self.addr) == 0:
self.show_warning(_(
'A hostname or IP address must be specified'
))
# test if port is OK
elif len(self.port) == 0 or int(self.port) < 1 or int(self.port) > 65534:
self.show_warning(_(
'The specified port must be a number between 1 and 65534'
))
else:
return response