def on_switch1_changed(self,widget,data): if self.switch1.get_active(): if os.path.exists(comun.TOKEN_FILE): os.remove(comun.TOKEN_FILE) else: gta = GTAService(token_file = comun.TOKEN_FILE) if gta.do_refresh_authorization() is None: authorize_url = gta.get_authorize_url() ld = LoginDialog(authorize_url) ld.run() gta.get_authorization(ld.code) ld.destroy() if gta.do_refresh_authorization() is None: md = Gtk.MessageDialog( parent = self, flags = Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, type = Gtk.MessageType.ERROR, buttons = Gtk.ButtonsType.OK_CANCEL, message_format = _('You have to authorize Google-Task-Indicator to use it, do you want to authorize?')) if md.run() == Gtk.ResponseType.CANCEL: exit(3) else: if gta.do_refresh_authorization() is None: exit(3) self.switch1.set_active(True) self.liststore.clear() self.liststore.append([_('All'),None]) for tasklist in gta.get_tasklists().values(): self.liststore.append([tasklist['title'],tasklist['id']]) self.entry2.set_active(0)
def on_entry1_activate(self, widget, status): pi = Picasa(token_file=comun.TOKEN_FILE) if self.entry1.get_active(): if pi.do_refresh_authorization() is None: authorize_url = pi.get_authorize_url() ld = LoginDialog(authorize_url) ld.run() pi.get_authorization(ld.code) ld.destroy() else: pi.revoke_authorization() self.entry1.set_active(pi.do_refresh_authorization() is not None)
def on_switch1_changed(self, widget, data): if self.switch1.get_active(): if os.path.exists(comun.TOKEN_FILE): os.remove(comun.TOKEN_FILE) else: googlecalendar = GoogleCalendar(token_file=comun.TOKEN_FILE) if googlecalendar.do_refresh_authorization() is None: authorize_url = googlecalendar.get_authorize_url() ld = LoginDialog(authorize_url) ld.run() googlecalendar.get_authorization(ld.code) ld.destroy() if googlecalendar.do_refresh_authorization() is None: md = Gtk.MessageDialog( parent=self, flags=Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, type=Gtk.MessageType.ERROR, buttons=Gtk.ButtonsType.OK_CANCEL, message_format= _('You have to authorize Calendar-Indicator to use it, do you want to authorize?' )) if md.run() == Gtk.ResponseType.CANCEL: exit(3) else: if googlecalendar.do_refresh_authorization() is None: exit(3) self.switch1.set_active(True) self.store.clear() for calendar in googlecalendar.get_calendars().values(): self.store.append([ calendar['summary'], tohex(random.randint(0, 16777215)), tohex(random.randint(0, 16777215)), calendar['id'], True, calendar['summary'] ])
import sys from PyQt5.Qt import * from logindialog import LoginDialog from mainwindow import MainWindow import helper if __name__ == '__main__': app = QApplication(sys.argv) helper.dbConnect() loginDialog = LoginDialog() isAuth = False result = -1 while not isAuth: result = loginDialog.exec_() if result == LoginDialog.Success or LoginDialog.Rejected: isAuth = True else: isAuth = False if result == LoginDialog.Success: w = MainWindow() w.show() app.exec_() sys.exit(-1)
data, params, first=False) return None if __name__ == '__main__': import random import time nonce = random.randint(1000000, 10000000) timestamp = time.time() print(time.time()) print(nonce) uo = UbuntuOne('token') authorize_url = uo.get_authorize_url() print(authorize_url) ld = LoginDialog(authorize_url) ld.run() #pi.get_authorization(ld.code) ld.destroy() uo.arq( 'POST', 'https://one.ubuntu.com/oauth/request/', None, data= "realm='', oauth_version='1.0', oauth_nonce='%s', oauth_timestamp='%s', oauth_consumer_key='ubuntuone', oauth_signature_method='PLAINTEXT', oauth_signature='hammertime'" % (nonce, timestamp)) exit(0)
def login(self): dialog = LoginDialog() dialog.show()
__author__ = 'Oswald A Smith' __title__ = 'tas' __version__ = '1.0' __license__ = 'MIT' __copyright__ = '2014 Oswald A Smith' import sys from PyQt5.QtCore import * from PyQt5.QtWidgets import * from logindialog import LoginDialog from mainwindow import MainWindow if __name__ == '__main__': app = QApplication(sys.argv) login_dialog = LoginDialog() login_dialog.show() main_window = MainWindow() main_window.show() app.exec_()