本文整理汇总了Python中remote.Remote.getUser方法的典型用法代码示例。如果您正苦于以下问题:Python Remote.getUser方法的具体用法?Python Remote.getUser怎么用?Python Remote.getUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类remote.Remote
的用法示例。
在下文中一共展示了Remote.getUser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainWindow
# 需要导入模块: from remote import Remote [as 别名]
# 或者: from remote.Remote import getUser [as 别名]
class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.setupUi(self)
# init subsystems
self.config = Config()
self.config.read()
self.config.set_defaults()
self.remote = Remote(self.config)
self.updates_layout = QtGui.QVBoxLayout(self.scrollAreaWidgetContents)
self.updates_layout.setMargin(1)
self.storage = UpdatesStorage(os.path.expanduser(self.config['qttt']['db_path']),
self.updates_layout, self.remote)
# gui options
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.tray = QtGui.QSystemTrayIcon(self)
icon = QtGui.QIcon(os.path.join(os.path.dirname(__file__), 'icon.png'))
self.tray.setIcon(icon)
self.setWindowIcon(icon)
self.tray.show()
self.gb_current.hide()
self.move( self.config['qttt']['geometry']['left'],
self.config['qttt']['geometry']['top'] )
self.resize(self.config['qttt']['geometry']['width'],
self.config['qttt']['geometry']['height'] )
self.setWindowTitle('QTTT - %s' % self.config['site']['base_url'])
self.lb_current.setWordWrap(True)
# connections
self.connect(self.action_Qt, QtCore.SIGNAL('activated()'), QtGui.qApp.aboutQt)
self.connect(self.pb_update, QtCore.SIGNAL('clicked()'), self.sendUpdate)
self.connect(self.le_update, QtCore.SIGNAL('returnPressed()'), self.sendUpdate)
self.connect(self.pb_stop, QtCore.SIGNAL('clicked()'), self.finishLast)
self.connect(self.tray, QtCore.SIGNAL('activated(QSystemTrayIcon::ActivationReason)'), self.trayActivated)
self.connect(QtGui.qApp, QtCore.SIGNAL('lastWindowClosed()'),self.writeConfig)
self.refresh_timer = QtCore.QTimer()
self.refresh_timer.setInterval(5*60*1000) # 5 minutes
self.connect(self.refresh_timer, QtCore.SIGNAL('timeout()'), self.getUpdates)
self.refresh_timer.start()
self.last_update_timer = QtCore.QTimer()
self.last_update_timer.setInterval(1000) # 1 second
self.connect(self.last_update_timer, QtCore.SIGNAL('timeout()'), self.refreshLastUpdateTime)
# retrieve data
try:
user = self.remote.getUser()
except:
QtGui.QMessageBox.warning(self, u"Ошибка", u"Не могу соединиться с сервером")
# it's hard but it's WORKING! :)
exit()
if user.get('error') is not None:
QtGui.QMessageBox.warning(self, u"Ошибка", u"Неверный api-key указан в .tttrc файле")
# it's hard but it's WORKING! :)
exit()
Update.set_current_user(user['nickname'])
self.storage.loadUpdatesFromDB()
self.getUpdates()
self.getProjects()
def writeConfig(self):
self.config['qttt']['geometry']['width'] = self.size().width()
self.config['qttt']['geometry']['height'] = self.size().height()
self.config['qttt']['geometry']['left'] = self.pos().x()
self.config['qttt']['geometry']['top'] = self.pos().y()
self.config.write()
def showMessage(self, title, message, status=None, only_status=False):
self.statusBar().showMessage(status if status else message, 5000)
if not only_status:
self.tray.showMessage(title, message)
def showLastUpdate(self, upd):
self.lb_current.setText(upd.message)
self.last_update_started_at = upd.started_at # it's easy to remember this time
self.refreshLastUpdateTime()
self.last_update_timer.start()
self.gb_current.show()
def hideLastUpdate(self):
self.last_update_timer.stop()
self.gb_current.hide()
self.tray.setToolTip('')
#.........这里部分代码省略.........