def __call__(self): print('1 for start\n2 for custom time') key = getch.getKey() if key == '1': print('Watcher started') while True: if self.findNodes(): duration = 150 for x in range(3): call(['termux-vibrate', '-d ' + str(duration)]) else: print('last check:' + set_time.setTime()) time.sleep(60) elif key == '2': rnodes = pickling.read() for node in rnodes: if node.__class__.__name__ == 'Timeline': timeline = node node = nodes.Node.Node(title=set_time.setTimeInteractive()) timeline.setChild(node) vibrate = Vibrate() vibrate.setChild(node) rnodes.append(node) rnodes.append(vibrate) pickling.write(rnodes)
def __call__(self): # no way to pass args as you are not going to invoke function, to be changed later to a special "function" mode cmds = [self.printMarkers, self.customMarker] [ print(str(index) + ' ' + cmd.__name__) for index, cmd in enumerate(cmds) ] key = getch.getKey() try: out = cmds[int(key)]() if out: #print(out) rnodes = pickling.read() for node in rnodes: if node.__class__.__name__ == 'Timeline': timeline = node print('timeline found') break else: print('timeline not found') timeline.setChild(out[-1]) rnodes += out pickling.write(rnodes) except Exception: traceback.print_exc()
def findNodes(self): rnodes = pickling.read() for node in rnodes: if node.__class__.__name__ == 'Vibrate': for child in node.children: if child.title[:-3] == set_time.setTime()[:-3]: return True
def __call__(self): for index, node in enumerate(pickling.read()): try: print(str(index).rjust(4, ' ') + ' ', end='') print(('children:' + str(len(node.children))).ljust(10, ' ') + ' ', end='') print(node.title) except Exception: print(str(index).rjust(4, ' ') + ' ', end='') print('has no title')
def __call__(self): parent = input('parentID:') child = input('childID:') rnodes = pickling.read() try: parent = int(parent) child = int(child) rnodes[parent].setChild(rnodes[child]) pickling.write(rnodes) except Exception: traceback.print_exc()
def __call__(self): print('>Search called<') search = input('search:') rnodes = pickling.read() for index, node in enumerate(rnodes): if node.title == search: try: print(str(index).rjust(4, ' ') + ' ', end='') print(('children:' + str(len(node.children))).ljust( 10, ' ') + ' ', end='') print(node.title) except Exception: print(str(index).rjust(4, ' ') + ' ', end='') print('has no title')
def printMarkers(self, specific=''): groups = [] rnodes = pickling.read() for node in rnodes: #find yourself created in DB if node.__class__.__name__ == 'Timeline': first_self = node first_self.children.sort(key=lambda x: x.title) #append groups [parent_name,marker] for child in first_self.children: for node in rnodes: try: #if node.title == 'created': if child in node.children: groups.append([node, child]) except Exception: pass #append group elements nodes, it'll be [node,parent_name,marker] for obj in groups: #found = False for node in rnodes: try: if obj[0] in node.children: obj.insert(0, node) found = True except Exception: pass #print(groups) for obj in groups: #try is for the case of obj element not having len of 3 try: print(obj[2].title + ':' + obj[1].title.ljust(10, ' ') + ':' + obj[0].title) except Exception: pass break
def __call__(self): node_title = input('title:') while node_title != '': rnodes = pickling.read() for node in rnodes: if node.__class__.__name__ == 'Timeline': timeline = node print('timeline found') break else: print('timeline not found') node = nodes.Node.Node(title=node_title) #notice parent_name = 'created', special keyword parent_marker = timeline.customMarker(parent_name='created') node.setChild(parent_marker[0]) timeline.setChild(parent_marker[1]) rnodes = rnodes + [node] + parent_marker #print(timeline.children) pickling.write(rnodes) node_title = input('title:')
import pickling import getch import traceback import nodes from subprocess import call try: call(['termux-wake-lock']) print('called wakelock') except Exception: print('wake lock exception') rnodes = pickling.read() nodes = [] for node in rnodes: if '__call__' in dir(node): nodes.append(node) def printOptions(): print('--options--') for index, node in enumerate(nodes): print(str(index).rjust(2, '0') + ' ', end='') try: print(node.title) except Exception: print('has no title') key1 = ''