def returnFromInitialAuthorization(self): rtmom_net.getInternetConnector().connectAuthorizedClicked(self.conn, self.tokenPath) self._myrtmom.updateFromNet(netConnector) self._myrtmom.doSaveToFile(self._fileHandler) self.rtmom_page.promote() self._finishOffInit()
def __init__(self, main): """ Initialize app page Data is attempted to load from cache (local file); if this fails, attempts it made to load from the net. """ self.main = main self._listMapping = {} mainbox = elementary.Box(self.main.win) mainbox.size_hint_weight_set(-1.0, -1.0) mainbox.show() self._mainbox = mainbox self._myrtmom = rtmom.RTMOM() self._fileHandler = rtmom_fs.FileHandler() try: self._myrtmom.doLoadFromFile(self._fileHandler) except: # Fine - this is our very first run; but now we direct connection to RTM print "Error when loading from cache ... trying direct pull from Internet" netConnector = rtmom_net.getInternetConnector() if not netConnector.isConnected(): self.conn, self.tokenPath = netConnector.connect(interactive = False) if self.conn: # Not none means, authorization request a = AuthorizedDialog(self.main, self, self.conn.getAuthURL()) a.promote() else: self._finishOffInit()
def doCompleteTask(self, catName = None, fullTask = None): """ Really doing the stuff for the action handler; allows for re-use when calling from outside (tasks details page) """ if not catName: catName = self.hs_cat.label_get() if not fullTask: item = self.list.selected_item_get() fullTask = self._listMapping[item] netConnector = rtmom_net.getInternetConnector() if not netConnector.isConnected(): netConnector.connect() self._myrtmom.markTaskComplete(netConnector, catName, fullTask) self._myrtmom.updateFromNet(netConnector) self._myrtmom.doSaveToFile(self._fileHandler) self._updateList(catName)
def playWithConnections(): import rtmom_net net = rtmom_net.getInternetConnector() net.connect() # # tl = net._connection.timelines.create().timeline # print tl cats = net.loadCategories() t = {} for key, cat in cats.iteritems(): print "Kategorie: %s, %s" %(key, cat) tasks = net.loadFullTasks(cat) for task in tasks: print "\t%s" %(task.name)
def _actionsCallback(self, *args): """ Event handler for the drop down list for actions """ x, y, action = args print ("Action: %s" %(action)) if action == '8update': netConnector = rtmom_net.getInternetConnector() if not netConnector.isConnected(): netConnector.connect() self._myrtmom.updateFromNet(netConnector) self._myrtmom.doSaveToFile(self._fileHandler) self._updateList(self.hs_cat.label_get()) elif action == "0details": item = self.list.selected_item_get() fullTask = self._listMapping[item] a= DetailDialog(self.main, fullTask) a.promote() elif action == "1completed": self.doCompleteTask() elif action == "9about": a = AboutDialog(self.main) a.promote()