def getAnswerByQuestion(msg, isGroup=False, **params): def isMaRen(msg): keywords = [u"你妹的", u"骚", u"贱", u"不要脸", u"SB", u"傻逼", u"sb", u"无耻", u"下流", u"卑鄙"] for k in keywords: if k in msg: return True return False def isSafeCode(msg): keywords = ["__class__", "mro(", "__subclasses__", "**"] for k in keywords: if k in msg: return False return True if u"天王盖地虎" in msg: ret = u"宝塔镇河妖" elif isMaRen(msg): import words ret = random.choice(words.maren_sentences) elif msg.startswith("#@fledna") and isSafeCode(msg): code = msg import util ret = util.exec_output(msg) reload(time) ret = u"===== @%s ===== \n%s" % (params["sender"], ret) elif isGroup: ret = "" else: ret = u"然后呢?" return cgi.escape(ret, quote=True).replace("'", "'")
def run_exp(args): # command expansion must be done in two phases: # first, inputs are expanded and indentified # then, the experimental hash is computed and substituted # if arguments are partially specified, fill them in from previous # runs args = fill_last_args(args) # now fill in any missing arguments that have defaults args = fill_defaults(args) # now make sure we have all the necessary arguments check_args(args) # find out the hash of experimental commit hsh = util.exec_output(['git', 'rev-parse', args.commit]).strip() # parse parameters from command line params = parse_params(args.params) job = dag.dag_node(args.description, params, hsh, args.command, rerun = args.rerun, subdir_only = args.subdir_only) jobs = dag.dag([job,]) lb = local_backend.local_backend() jobs.backend = lb jobs.mainloop()
def run_file(args): filename=args.file #Parse the file parse_file(filename) # Get the current commit hash commit=util.exec_output(['git', 'rev-parse', 'HEAD']).strip() # Fill in this commit wherever HEAD occurs fill_in_commit(commit) # Create a new task task_id=save_task(filename, commit) print 'The id for this task is {}'.format(str(task_id)) # Start running run()
#!/usr/bin/env python import dag, util, local_backend import time # this file is just for testing; if a user actually wanted to run a # job they'd use exp.py. hsh = util.exec_output(['git', 'rev-parse', 'HEAD']).strip() test_node = dag.dag_node(desc = "testscript", commit = hsh, command = "./test.sh") test_node2=dag.dag_node(desc = "testscript2", commit = hsh, command = "./test2.sh {testscript}/log") test_node2.add_parents(set([test_node,])); test_dag = dag.dag([test_node,]) lb = local_backend.local_backend() test_dag.backend = lb test_dag.mainloop()