def main(): """ Gets login credentials from the user and establishes a connection to the TigerGraph database """ st.title("TigerGraph Visual Query Tool") st.write("Welcome to my first Streamlit + TigerGraph project connecting a web application to a graph database and visualizing query data.") graph = None authToken = None sb = st.sidebar sb.header("Connect to TigerGraph Database") host = sb.text_input("Host URL") username = sb.text_input("Username") password = sb.text_input("Password", type="password") graphname = sb.text_input("Graph Name") if sb.checkbox("Connect to Graph"): # establish connection to TG database graph = tg.TigerGraphConnection( host=host, username=username, password=password, graphname=graphname, ) st.success(f"Connected to {graphname} graph") secret = sb.text_input("Secret", type="password") if (sb.checkbox("Get Auth Token")): # get auth token using user inputted secret authToken = graph.getToken(secret) tasks.main(graph, authToken)
def main(): run = True connection = MongoClient() database = connection[DATABASE_NAME] menu = """ Main Menu -[T]asks -([C]ontacts) WARNING: Not yet implemented! -[Q]uit Please enter the square bracketed letter of the menu option you wish to use [T]: """ while run == True: currentMenu = raw_input(menu) if currentMenu == "": currentMenu = "T" if currentMenu.upper().startswith("C"): contacts.main(database.contacts) elif currentMenu.upper().startswith("T"): tasks.main(database.tasks) elif currentMenu.upper().startswith("Q"): run = False
from eventlet.green import urllib2 import tasks def fetch(url): body = urllib2.urlopen(url).read() tasks.logger.debug("%s - %s" % (url, body)) if __name__ == '__main__': tasks.set_func(fetch) tasks.main()
def test_main_h_exits_with_0(self): with self.assertRaises(SystemExit) as cm: tasks.main(['-h']) self.assertEqual(0, cm.exception.code)
def setUp(self): from tasks import main app = main({}) from webtest import TestApp self.testapp = TestApp(app)
taskqueue = dispatcher.make_queue() for i in xrange(num_tasks): taskqueue.push(random_task(SlowSquare)) for i in xrange(num_tasks // 2): info(' Got %r', taskqueue.pop()) taskqueue.close() for i in xrange(num_tasks // 2, num_tasks): try: info(' Got %r', taskqueue.pop()) except papyros.ClosedTaskQueueError: info(' Task queue closed') break except Exception, ex: # PyroTaskQueue may raise ProtocolError/ConnectionClosedError exception_info(ex) break if __name__ == '__main__': dispatcher, options = main( Option('-n', '--num_tasks', type='int', default=10, help='Number of tasks')) num_tasks = options.num_tasks test_pop_blocking() test_pop_nonblocking(timeout=0.5) test_pop_many(timeout=3) test_close()
def test_main_h_exits_with_0(self): exit_code = tasks.main(['-h']) self.assertEqual(0, exit_code)
# starting the queues in a separate function to make sure that no locals are # kept around after it returns def closure(): for i in xrange(num_tasks): task = random_task(PrimeFactors) info(' Task: %s', task) try: dispatcher.execute([task]).next() except Exception, ex: pass closure() time.sleep(0.1) # give time for all closed queues to die off num_queues = dispatcher.num_queues() assert not num_queues, 'Ending with %d queues instead of 0' % num_queues if __name__ == '__main__': dispatcher,options = main( Option('-n', '--num_tasks', type='int', default=10, help='Number of tasks'), Option('-o', '--ordered', action='store_true', default=False, help='Yield the results in the same order with the tasks'), Option('-c', '--chunksize', type='int', default=1, metavar='SIZE', help='Break the tasks into into slices of SIZE')) num_tasks = options.num_tasks ordered = options.ordered chunksize = options.chunksize test_execute(ordered, chunksize) test_execute_exception(ordered, chunksize) test_multiple_queues(ordered, chunksize) test_close_execute() test_autoclose()