Example #1
0
def split_call(toy, k):
    global COUNT, FCOUNT
    if not toy.params:  # Case for no argument function calls
        if type(toy.fun) == str:
            return call(toy.fun, k)
        elif type(toy.fun) == func:
            return call(value(toy.fun), k)
        else:
            return call(split(toy.fun, k), k)
    else:  # Normal case for any-argument calls
        received_expr = []
        function_args = []
        expressions = toy.params[::-1] + [toy.fun]
        for i in range(FCOUNT, len(expressions) + FCOUNT):
            function_args.append(new_var("f", i))
        FCOUNT += len(expressions)
        last_expr = call(function_args[-1], [k] + function_args[0:-1][::-1])
        for i in range(len(expressions)):
            received_expr.append(receive(expressions[i]))
        function_args.reverse()
        received_expr.reverse()
        for i in range(len(function_args)):
            last_expr = call(received_expr[i], func(function_args[i],
                                                    last_expr))
    return last_expr
Example #2
0
 def test_call(self):
     t_call = call(func([], 1), [])
     self.assertEqual(t_call.fun, func([], 1))
     self.assertEqual(t_call.params, [])
     t_call = call(func(["x"], 1), [1])
     self.assertEqual(t_call.fun, func(["x"], 1))
     self.assertEqual(t_call.params, [1])
Example #3
0
def projectinit(name,template,git=True):
    ''' Create a VT project directory by copying from a template resource tree.
    
    Args:
        name (str): Name of the new VT project directory.
        template (str): Template directory to copy from.
        git (bool): Whether to prepare the project directory for Git use.
    
    Yields:
        :func:`sys.exit` upon errors.

    Note: 
        :func:`os.chdir`\ s into the new VT project directory!
    '''
    try:
        shutil.copytree(template,name,symlinks=True)
    except OSError as exc:
        sys.exit('%s when initialising project directory from template'%exc)

    if git:
        try:
            os.chdir(name)
            call.call('git init',5)
            call.call('git add .',5)
        except call.callError as exc:
            sys.exit('Project directory created, but git initialization failed (%s)'%exc)
Example #4
0
 def call(self, uid, pwd, called, sign, pv, v, echo='1'):
     far_ip = cherrypy.request.remote.ip
     if 'User-Agent' in cherrypy.request.headers.keys():
         ieinfo = cherrypy.request.headers['User-Agent']
         if ieinfo.find('Mozilla') > -1:
             logger.info('受到恶意攻击!!!IP=%s, User-Agent=%s' % (far_ip, ieinfo))
             return 'hehe'
     if (not uid) or (not called) or (not pwd) or (not sign) or (not pv) or (not v):
         logger.info('传入参数错误!')
         return '{"result":"-10"}'
     called = called.replace(' ', '')
     called = called.replace('-', '')
     if (called[0] == '+'):
         called = called[1:]
     if ((called.isdigit() == False) or (uid.isdigit() == False) or (echo != '0' and echo != '1')):
         logger.info('传入参数错误!')
         return '{"result":"-10"}'
     if sign != md5.new(uid + config.key).hexdigest():
         return '{"result":"-6"}'
     try:
         ln = len(called)
         if ((ln >= 2) and (ln <= 4)):
             called = tool.get_called_by_cornet(uid, called)
         if called:
             result = call.call(uid, pwd, called, echo, far_ip)
             logger.info("pv=%s, v=%s, uid=%s, called=%s, echo=%s" % (pv, v, uid, called, echo))
             return str(result)
         else:
             logger.info("%s呼叫%s,短号相应的号码获取失败" % (uid,called))
             return '{"result":"-3"}'
     except:
         logger.info("call proc exception: %s " % traceback.format_exc())
         return '{"result":"-11"}'
def check_for_objects():
    while True:
        try:
            global last_epoch
            frame, found_obj = video_camera.get_object()
            if found_obj and (time.time() -
                              last_epoch) > email_update_interval:
                last_epoch = time.time()
                call('+918465094927')
                sending(frame)
                print("all ok")
                now = datetime.now()
                current_time = now.strftime("%H:%M:%S")
                print(current_time)
        except:
            print("Error in sending email")
Example #6
0
 def free_call(self, caller, callee, pwd, agent_id, agent_name, sign):
     far_ip = cherrypy.request.remote.ip
     try:
         if (not caller) or (not callee) or (not pwd) or (not agent_id) or (not agent_name):
             logger.info('传入参数错误!')
             return '-1'
         if ((pwd.isalnum() == False) or (callee.isdigit() == False) or (caller.isdigit() == False)):
             logger.info('传入参数错误!')
             return '-1'
         if sign != md5.new(caller + config.key).hexdigest():
             return '{"result":"-12"}'
         logger.info('free call: caller:%s,callee:%s,agent_id:%s,agent_name:%s' % (caller,callee,agent_id,agent_name.decode('gbk')))
         passwd = tool.cryptData(pwd)
         result = reg.register(caller, passwd, agent_id, 1, far_ip)
         tmp = json.loads(result)
         res = tmp['result']
         if callee == caller:
             return res
         else:
             if res != '0':
                 return res
             result = call.call(str(tmp['uid']), passwd, callee, '1', far_ip)
             tmp = json.loads(result)
             return tmp['result']
     except:
         logger.info("reg proc exception: %s " % traceback.format_exc())
         return '-1'
def evaluate(points, *args):
    maxholder = args[0]
    value = call.call(points)
    if value > maxholder.get_x():
        if acceptable.acceptable(points):
            maxholder.set_x(value)
            maxholder.set_points(points)
    return value
Example #8
0
def sd(var, data, depth, index, context):
    if type(data) == str:
        if data == var:
            return [depth, index]
        else:
            return "_"
    elif type(data) == int:
        return data
    elif type(data) == func:
        rightness = 0
        for arg in data.args:
            if arg != var:
                data.body = sd(var, data.body, depth + 1, index, context)
                data.body = sd(arg, data.body, 0, rightness, context + 1)
            else:
                data.body = sd(arg, data.body, depth, index, context + 1)
            rightness += 1
        removed_s = []
        for s in data.args:
            removed_s.append("_")
        data.args = removed_s
        return data
    elif type(data) == call:
        param_list = []
        for param in data.params:
            param_list.append(sd(var, param, depth, index, context))
        f = sd(var, data.fun, depth, index, context)
        return call(f, param_list)
    elif type(data) == cond:
        condition = sd(var, data.condition, depth, index, context)
        t = sd(var, data.true_expression, depth, index, context)
        f = sd(var, data.false_expression, depth, index, context)
        return cond(condition, t, f)
    elif type(data) == decl:
        if data.var != var:
            data.rhs = sd(var, data.rhs, depth, index, context)
            data.rhs = sd(data.var, data.rhs, 0, context, context)
        else:
            data.rhs = sd(data.var, data.rhs, 0, context, context)
        data.var = "_"
        return data
    elif type(data) == declSequence:
        seq = data.sequence
        seq.append(data.expr)
        new_sequence = sd(var, seq, depth, index, context)
        return declSequence(new_sequence)
    elif type(data) == list:
        if len(data) > 1:
            if type(data[0]) == decl:
                data[1:] = sd(data[0].var, data[1:], depth, context,
                              context + 1)
            data[1:] = sd(var, data[1:], depth, index, context + 1)
            data[0] = sd(var, data[0], depth, index, context)
        else:
            if type(data[0]) == list:
                depth += 1
            data[0] = sd(var, data[0], depth, index, context)
        return data
Example #9
0
 def test_parse_list(self):
     t_json = ["fun*", [], 1]
     self.assertEqual(parseList(t_json), func([], 1))
     t_json = ["call", "+", 1, 2]
     self.assertEqual(parseList(t_json), call("+", [1, 2]))
     t_json = ["let", "x", "=", ["fun*", [], 1]]
     self.assertEqual(parseList(t_json), decl("x", func([], 1)))
     t_json = ["a", "b", "c"]
     self.assertEqual(parseList(t_json), ["a", "b", "c"])
Example #10
0
def Ping():
    call.call("logger ping.py started")
    output = call.call("ping -c4 www.google.com")
    print output

    f = open('log.txt', 'a')
    f.write(output)

    rate = output.find('received')
    if rate > 2:
        pack = rate - 2
        p1 = output[pack]
        p = int(p1)

    else:
        p = 0
    #print p
    if p < 3:

        restart = call.call("sudo service network-manager restart")
        time.sleep(30)
        call.call("logger network manager restarted by ping.py")
        print("network-manager restarted")

    f.close()
Example #11
0
def reproject_to(ref_file, in_tag='orig', out_tag='repro',
                 interpol_dict={'order': 3},
                 clobber=True):
    """Reproject cubes e.g. to match a HESS survey map.

    Can be computationally and memory intensive if the
    HESS map is large or you have many energy bands."""
    logging.info('Reprojecting to {0}'.format(ref_file))
    ref_image = FITSimage(ref_file)
    for ii in range(len(components)):
        in_file = filename(in_tag, ii)
        out_file = filename(out_tag, ii)
        logging.info('Reading {0}'.format(in_file))
        in_image = FITSimage(in_file)
        logging.info('Reprojecting ...')
        out_image = in_image.reproject_to(ref_image.hdr,
                                          interpol_dict=interpol_dict)
        logging.info('Writing {0}'.format(out_file))
        out_image.writetofits(out_file, clobber=clobber)
        logging.info('Copying energy extension')
        cmd = ['fappend',
               '{0}[ENERGIES]'.format(in_file),
               '{0}'.format(out_file)]
        call(cmd)
Example #12
0
def parseList(jso):
    if len(jso) > 0:
        if jso[0] == "fun*":
            body = parse(jso[2])
            return func(jso[1], body)
        if jso[0] == "call":
            params = []
            for parameter in jso[2:]:
                params.append(parse(parameter))
            c = call(parse(jso[1]), params)
            return c
        if jso[0] == "if-0":
            return cond(parse(jso[1]), parse(jso[2]), parse(jso[3]))
        if jso[0] == "let":
            return decl(jso[1], parse(jso[3]))
        # No need for infix operation checking in the list section, since it cannot happen
        if jso[0] == "seq*":
            args = []
            for s in jso[1:-1]:
                p = parse(s)
                args.append(p)
            f = call(func(rand_stringer(len(args)), parse(jso[-1])),
                     args[::-1])
            return f
        if jso[0] == "grab":
            return grab(parse(jso[1]), parse(jso[2]))
        if jso[0] == "stop":
            return stop(parse(jso[1]))
        if type(jso) == list:
            return_array = []
            for item in jso:
                return_array.append(parse(item))
            if len(return_array) > 1 and type(return_array[0]) == decl:
                return declSequence(return_array)
            return return_array
    return jso
Example #13
0
def split(toy, k):
    global COUNT
    if type(toy) == str:
        if toy in opList:
            return call(k, ops_mapping[toy])
        return call(k, toy)
    if type(toy) == int:
        return call(k, toy)
    if type(toy) == func:
        return call(k, value(toy))
    if type(toy) == call:
        return split_call(toy, k)
    if type(toy) == cond:
        conditional = cond("of-tst", split(toy.true_expression, k),
                           split(toy.false_expression, k))
        f = func(["of-tst"], conditional)
        return call(receive(toy.condition), f)
    if type(toy) == decl:
        toy.rhs = value(toy.rhs)
        return toy
    if type(toy) == declSequence:
        new_sequence = []
        for declaration in toy.sequence:
            new_sequence.append(split(declaration, k))
        toy.sequence = new_sequence
        toy.expr = split(toy.expr, k)
        return toy
    if type(toy) == grab:
        return declSequence(
            [decl(toy.var, func(["x", "f"], call(k, "f"))),
             split(toy.rhs, k)])
    if type(toy) == list:
        if len(toy) < 1:
            return k  # ?
        else:
            call_arg = func(["of-rst"], call(k, "of-rst"))
            f = func(["of-fst"], call(receive(toy[1:]), call_arg))
            return call(receive(toy[0]), f)
    if type(toy) == stop:
        return stop(receive(toy.toy))
Example #14
0
def handleList(toy, env, store):
    """
    where handle list comes in:
     - single item lists
     - list of toy where the 2nd element will evaluate to a primop
    """
    if len(toy) == 1:
        return interpret(toy[0], env, store)
    else:
        # plan: interpret each item in list  R->L, check, then applyPrimop on [first, third->]
        prim, newStore = interpret(toy[1], env, store)
        if type(prim) == primop:
            args = toy[2:]
            args.insert(0, toy[0])
            return primopApply(prim, args, env, newStore)
        elif type(prim) == funcVal:
            args = toy[2:]
            args.insert(0, toy[0])
            return handleCall(call(toy[1], args), env, store)
        else:
            for i in toy[2:][::-1]:
                v, newStore = interpret(i, env, newStore)
            raise errors.ClosureOrPrimopExpected(newStore)
Example #15
0
    def test_cps(self):
        # Using the alpha_equals() for equality

        t_json = 1
        parsed_json = parse(t_json)
        cps = receive(parsed_json)
        test = func(["k1"], call("k1", [1]))
        self.assertTrue(alpha_equal(cps, test))

        t_json = "a"
        parsed_json = parse(t_json)
        cps = receive(parsed_json)
        test = func(["k2"], call("k2", ["a"]))
        self.assertTrue(alpha_equal(cps, test))

        t_json = "+"
        parsed_json = parse(t_json)
        cps = receive(parsed_json)
        test = func(["k3"], call("k3", ops_mapping["+"]))
        self.assertTrue(alpha_equal(cps, test))

        t_json = ["call", ["fun*", ["x", "y"], "y"], 1, 2]
        parsed_json = parse(t_json)
        cps = receive(parsed_json)
        test = func("k5", call(func("k6", call("k6", 2)),
                               func("of-1", call(func("k7", call("k7", 1)),
                                                 func("of-0",
                                                      call(func(["k8"],
                                                                call("k8",
                                                                     func(["k", "x", "y"], call("k", "y")))),
                                                           func("of-f",
                                                                call("of-f", ["k5", "of-0", "of-1"]))))))))
        self.assertTrue(alpha_equal(cps, test))

        t_json = ["if-0", 0, 1, 2]
        parsed_json = parse(t_json)
        cps = receive(parsed_json)
        test = func(["k9"], call(func(["k10"], call("k10", [0])), func(["of-tst"], cond("of-tst",
                                                                                        call("k9", [1]),
                                                                                        call("k9", [2])))))
        self.assertTrue(alpha_equal(cps, test))

        t_json = [["let", "a", "=", 5], ["let", "b", "=", 6], "b"]
        parsed_json = parse(t_json)
        cps = receive(parsed_json)
        test = declSequence([decl("a", 5), decl("b", 6), func(["k11"], call("k11", ["b"]))])
        self.assertTrue(alpha_equal(cps, test))

        t_json = ["fun*", ["x"], "x"]
        parsed_json = parse(t_json)
        cps = receive(parsed_json)
        test = func(["k12"], call("k12", func(["k", "x"], call("k", ["x"]))))
        self.assertTrue(alpha_equal(cps, test))

        # Unit tests against names we would generate
        t_json = ["fun*", ["kb"], "kb"]
        parsed_json = parse(t_json)
        cps = receive(parsed_json)
        test = func(["k12"], call("k12", func(["k", "kb"], call("k", ["kb"]))))
        self.assertTrue(alpha_equal(cps, test))

        t_json = ["call", "+", 1, 2]
        parsed_json = parse(t_json)
        cps = receive(parsed_json)
        test = func("k13", call(func("k14", call("k14", 2)),
                                func("of-1",
                                     call(func("k15", call("k15", 1)),
                                          func("of-0", call(func("k", call("k", ops_mapping["+"])),
                                                            func("k", call("k", ["k13", "of-0", "of-1"]))))))))
        self.assertTrue(alpha_equal(cps, test))

        t_json = ["grab", "x", ["call", "x", 10]]
        parsed_json = parse(t_json)
        cps = receive(parsed_json)
        test = func(["k"], declSequence([decl("x", func(["x", "f"], call("k", "f"))),
                                         call(func("kc", call("kc", 10)),
                                              func("fa",
                                                   call(func("kd", call("kd", "x")),
                                                        func("fb", call("fb", ["kb", "fa"])))))]))
        self.assertTrue(alpha_equal(cps, test))

        t_json = ["stop", 10]
        parsed_json = parse(t_json)
        cps = receive(parsed_json)
        test = func("k", stop(func("kc", call("kc", 10))))
        self.assertTrue(alpha_equal(cps, test))

        t_json = ["call", "+", 1, ["stop", 10]]
        parsed_json = parse(t_json)
        cps = receive(parsed_json)
        test = func("k13", call(func("k", stop(func("kc", call("kc", 10)))),
                                func("of-1",
                                     call(func("k15", call("k15", 1)),
                                          func("of-0", call(func("k", call("k", ops_mapping["+"])),
                                                            func("k", call("k", ["k13", "of-0", "of-1"]))))))))
        self.assertTrue(alpha_equal(cps, test))

        t_json = declSequence([decl("x", 15), "x"])
        cps = receive(t_json)
        test = declSequence([decl("x", 15), func("ke", call("ke","x"))])
        self.assertTrue(alpha_equal(cps, test))
Example #16
0
def run(toy):
    app_form = func(["x"], stop("x"))
    cps_form = call(receive(toy), app_form)
    interp_ast(cps_form)
Example #17
0
 def test_seq(self):
     t_json_input = ["seq*", ["call", "+", ["call", "*", 5, 3], 1], -1]
     t_json_expected = call(func(["a"], -1), [call("+", [call("*", [5, 3]), 1])])
     self.assertTrue(alpha_equal(parse(t_json_input), t_json_expected))
Example #18
0
def call(params):
    callid = [params[1], params[2], params]
    callid = decode(callid)
    caller.call(callid)
Example #19
0
import sys
from call import call

if __name__ == '__main__':

    if len(sys.argv) == 2:
      call(sys.argv[1])
    else:
      print("Usage: python3 test.py YOURTEXTHERE")
Example #20
0
    def test_interpret(self):
        t_json = 1
        parsed_json = parse(t_json)
        toy = receive(parsed_json)
        env, store_ = interpret_init()
        result, new_store = stop_catch_interpretter(call(toy, func(["x"], "x")), env, store_)
        self.assertEqual(result, 1)

        t_json = ["fun*", [], 1]
        parsed_json = parse(t_json)
        toy = receive(parsed_json)
        env, store_ = interpret_init()
        result, new_store = stop_catch_interpretter(call(toy, func(["x"], "x")), env, store_)
        self.assertEqual(str(result), "\"closure\"")

        t_json = "!"
        parsed_json = parse(t_json)
        toy = receive(parsed_json)
        env, store_ = interpret_init()
        result, new_store = stop_catch_interpretter(call(toy, func(["x"], "x")), env, store_)
        self.assertEqual(str(result), "\"closure\"")

        t_json = ["call", "@", 1]
        parsed_json = parse(t_json)
        toy = receive(parsed_json)
        env, store_ = interpret_init()
        result, new_store = stop_catch_interpretter(call(toy, func(["x"], "x")), env, store_)
        self.assertEqual(str(result), "\"cell\"")

        t_json = "a"
        parsed_json = parse(t_json)
        toy = receive(parsed_json)
        env, store_ = interpret_init()
        self.assertRaises(errors.UndeclaredException,
                          stop_catch_interpretter, call(toy, func(["x"], "x")), env, store_)

        t_json = ["call", "^", 1, -1]
        parsed_json = parse(t_json)
        toy = receive(parsed_json)
        env, store_ = interpret_init()
        self.assertRaises(errors.exponentiationError,
                          stop_catch_interpretter, call(toy, func(["x"], "x")), env, store_)

        t_json = ["call", "^", 1]
        parsed_json = parse(t_json)
        toy = receive(parsed_json)
        env, store_ = interpret_init()
        self.assertRaises(errors.ArgumentParameterMismatch,
                          stop_catch_interpretter, call(toy, func(["x"], "x")), env, store_)

        t_json = ["call", 1]
        parsed_json = parse(t_json)
        toy = receive(parsed_json)
        env, store_ = interpret_init()
        self.assertRaises(errors.ClosureOrPrimopExpected,
                          stop_catch_interpretter, call(toy, func(["x"], "x")), env, store_)

        t_json = ["grab", "c", ["call", ["fun*", ["v"], ["call", "v", 10]], "c"]]
        parsed_json = parse(t_json)
        toy = receive(parsed_json)
        env, store_ = interpret_init()
        result, new_store = stop_catch_interpretter(call(toy, func(["x"], "x")), env, store_)
        self.assertEqual(result, 10)

        t_json = ["grab", "c", ["call", ["fun*", ["v"], ["call", "v", 10]], "c"]]
        parsed_json = parse(t_json)
        toy = receive(parsed_json)
        env, store_ = interpret_init()
        result, new_store = stop_catch_interpretter(call(toy, func(["x"], "x")), env, store_)
        self.assertEqual(result, 10)

        t_json = ["call", "+",
                  ["stop",
                   [["let", "y", "=", 10],
                    ["call", "^", 2, "y"]]],
                  10]
        parsed_json = parse(t_json)
        toy = receive(parsed_json)
        env, store_ = interpret_init()
        result, new_store = stop_catch_interpretter(call(toy, func(["x"], "x")), env, store_)
        self.assertEqual(result, 1024)

        t_json = ["call", "*",
                  ["call", ["fun*", [], 2]],
                  5]
        parsed_json = parse(t_json)
        toy = receive(parsed_json)
        env, store_ = interpret_init()
        result, new_store = stop_catch_interpretter(call(toy, func(["x"], "x")), env, store_)
        self.assertEqual(result, 10)

        t_json = ["call", ["fun*", [], 1]]
        parsed_json = parse(t_json)
        toy = receive(parsed_json)
        env, store_ = interpret_init()
        result, new_store = stop_catch_interpretter(call(toy, func(["x"], "x")), env, store_)
        self.assertEqual(result, 1)

        toy = func("k13", call(func("k", stop(func("kc", call("kc", 10)))),
                               func("of-1",
                                    call(func("k15", call("k15", 1)),
                                         func("of-0", call(func("k", call("k", ops_mapping["+"])),
                                                           func("k", call("k", ["k13", "of-0", "of-1"]))))))))
        env, store_ = interpret_init()
        result, new_store = stop_catch_interpretter(call(toy, func(["x"], "x")), env, store_)
        self.assertEqual(result, 10)

        toy = func(["kb"], declSequence([decl("x", func(["x", "f"], call("kb", "f"))),
                                         call(func("kc", call("kc", 10)),
                                              func("fa",
                                                   call(func("kd", call("kd", "x")),
                                                        func("fb", call("fb", ["kb", "fa"])))))]))
        env, store_ = interpret_init()
        result, new_store = stop_catch_interpretter(call(toy, func(["x"], "x")), env, store_)
        self.assertEqual(result, 10)

        toy = func("k13", call(func("k14", call("k14", 2)),
                               func("of-1",
                                    call(func("k15", call("k15", 1)),
                                         func("of-0", call(func("k", call("k", ops_mapping["+"])),
                                                           func("k", call("k", ["k13", "of-0", "of-1"]))))))))
        env, store_ = interpret_init()
        result, new_store = stop_catch_interpretter(call(toy, func(["x"], "x")), env, store_)
        self.assertEqual(result, 3)
Example #21
0
    sex_list = ('F', 'M', 'FEMALE', 'MALE')
    for line in F1:
        sep = line.rstrip().split('\t')
        if sep[0] not in midpool:
            midpool[sep[0]] = [sep[3]]
        else:
            midpool[sep[0]].append(sep[3])
        name_list.append(sep[2])

for batch in midpool.keys():
    batch_out = os.path.join(options.outdir, batch)
    if os.system('mkdir -p ' + batch_out) != 0:
        raise Exception('Failed to create dir for %s: %s\n' %
                        (batch, batch_out))

    sys.stderr.write(
        'Use samtools to get depth of each region for samples: %s\n' %
        ('\n'.join(midpool[batch])))
    sample_depth = depth_combine(midpool[batch], options.bed,
                                 os.path.join(batch_out, batch + '.depth.txt'),
                                 name_list)
    sample_rpkm = rpkm(sample_depth, options.read_length,
                       os.path.join(batch_out, batch + '.rpkm.txt'))
    sys.stderr.write(
        f'\nBegin to call CNV, threshold for deletion: {options.threshold_del}, duplication: {options.threshold_dup},sampleQC: {options.sampleQC}\n'
    )
    call(sample_rpkm, options.threshold_del, options.threshold_dup,
         options.sampleQC, os.path.join(batch_out, batch + '.rpkm.txt'))

sys.stderr.close()
 def amp(self, res=75):
     return call.call(self.points, res)
Example #23
0
def play():
    cont = True
    while cont == True:
        win.fill(colour('black'))

        display.button(int(d_width * 5 / 6), int(0.8 * d_height), 120, 60,
                       "d_red", "red", "quit")
        display.text_2_button(int(d_width * 5 / 6), int(0.8 * d_height),
                              "QUIT", "calibri", "black", 35)

        cmd_attt = display.button1(0, 180, 140, parameter='attt')
        cmd_dab = display.button1(1, 400, 140, parameter='dab')
        cmd_pm = display.button1(2, 600, 140, parameter='pm')
        cmd_s = display.button1(3, 180, 300, parameter='s')
        cmd_sdk = display.button1(4, 400, 300, parameter='sdk')
        cmd_tt = display.button1(5, 600, 300, parameter='tt')
        cmd_t = display.button1(6, 300, 470, parameter='t')
        display.text_2_button(180, 212, "Angry TicTacToe", 'Candara',
                              colour('cyan'))
        display.text_2_button(400,
                              210,
                              "Dots and Boxes",
                              'CG Omega',
                              colour('red'),
                              b=1)
        display.text_2_button(600, 210, "Pac-Man", 'digifacewide',
                              colour('d_yellow'))
        display.text_2_button(180, 372, 'Snakes', 'Consolas', colour('green'))
        display.text_2_button(400,
                              378,
                              'SuDoKu',
                              'Helvetica',
                              colour('purple'),
                              b=1)
        display.text_2_button(600, 372, 'Tank Maze', 'Monaco',
                              colour('orange'))
        display.text_2_button(415,
                              470,
                              'Tanks',
                              'Eurostile',
                              colour('d_grey'),
                              size=30)
        #stripe motion effect
        global x
        global y
        win.blit(eff_blue_hr, (x - eff_red_hl.get_rect().width, 30))
        win.blit(eff_red_hl, (d_width - x, 50))
        win.blit(eff_green_hl, (d_width - x, d_height - 30))
        win.blit(eff_lavender_hr,
                 (x - eff_lavender_hr.get_rect().width, d_height - 50))
        win.blit(eff_white_vu, (30, d_height - y))
        win.blit(eff_cyan_vd, (50, y - eff_cyan_vd.get_rect().height))
        win.blit(eff_yellow_vd,
                 (d_width - 30, y - eff_yellow_vd.get_rect().height))
        win.blit(eff_magenta_vu, (d_width - 50, d_height - y))
        x += 2
        y += 2
        if x == d_width + eff_red_hl.get_rect().width:
            x = 0
        if y == d_height + eff_white_vu.get_rect().height:
            y = 0

        #icon buttons

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                1 / 0
            else:
                pass
        clock.tick(200)
        pygame.display.update()

        ##launching game
        if cmd_attt != None:
            print('opening')
            call.call(cmd_attt)
            cmd_attt = None
            time.sleep(0.5)
        elif cmd_dab != None:
            call.call(cmd_dab)
            cmd_dab = None
            time.sleep(0.5)
        elif cmd_pm != None:
            call.call(cmd_pm)
            cmd_pm = None
            time.sleep(0.5)
        elif cmd_s != None:
            call.call(cmd_s)
            cmd_s = None
            time.sleep(0.5)
        elif cmd_sdk != None:
            call.call(cmd_sdk)
            cmd_sdk = None
            time.sleep(0.5)
        elif cmd_tt != None:
            call.call(cmd_tt)
            cmd_tt = None
            time.sleep(0.5)
        elif cmd_t != None:
            call.call(cmd_t)
            cmd_t = None
            time.sleep(0.5)
        else:
            pass
Example #24
0
import operator
from func import func
from call import call
from primop import primop
from errors import exponentiationError

opList = ["+", "*", "^", "@", "!", "="]

ops_mapping = {
    "+": func(["k", "x", "y"], call("k", [call("+", ["x", "y"])])),
    "*": func(["k", "x", "y"], call("k", [call("*", ["x", "y"])])),
    "^": func(["k", "x", "y"], call("k", [call("^", ["x", "y"])])),
    "@": func(["k", "x"], call("k", [call("@", ["x"])])),
    "!": func(["k", "x"], call("k", [call("!", ["x"])])),
    "=": func(["k", "x", "y"], call("k", [call("=", ["x", "y"])])),
}
"""
    Below are the arithmetic/memory functions that evaluate prim-ops
    All of them take in an Array of arguments and return the operation
    applied to the arguments (The final argument is always a Store)
"""


def plus_op(a):
    return operator.add(*a[:2]), a[2]


def mult_op(a):
    return operator.mul(*a[:2]), a[2]

    "Name": [],
    "Action_rgb": [],
    "Romance_rgb": [],
    "Drama_rgb": [],
    "Horror_rgb": [],
    "Action": [],
    "Drama": [],
    "Horror": [],
    "Romance": [],
    "Action_audio": [],
    "Romance_audio": [],
    "Drama_audio": [],
    "Horror_audio": []
}

path_dir = input("enter the path of the video folder\n")
path = Path(path_dir)
for video_path in os.listdir(path_dir):
    if video_path[0] != '.':
        new_path = os.path.join(path_dir, video_path)
        print(new_path)
        name = video_path.split(".")[0]
        result_dict = call.call(new_path)
        for key in final_dict.keys():
            if (key == "Name"):
                final_dict[key].append(name)
            else:
                final_dict[key].append(result_dict[key][0])

df = pd.DataFrame(final_dict)
df.to_csv(os.path.join(os.getcwd(), "final_results.csv"), index=False)
Example #26
0
    def add(self, new):
        self.calls.append(new)
        return self

    def remove(self):
        del self.calls[0]
        return self

    def info(self):
        for x in range(0, self.queue):
            print self.calls[x].name, self.calls[x].number
        return self

    # def removeuser(self,phonenumber):
    #     for x in range(0,self.queue-1):
    #         if self.calls[x].number == phonenumber:           I'm going to come back to this assignment to achieve hacker eventually.
    #             del self.calls[x]

    #     return self


call1 = call(1, "John", 123, "Need a car")
call2 = call(2, "Mary", 456, "Have a car")
call3 = call(3, "Does", 789, "Sold a car")
calls = callcenter(call1, call2, call3)

calls.info()

# calls.removeuser(456)
# calls.info()
Example #27
0
def generate_icon(icon_in, icon_out, size):
    call('convert {} -resize {}x{} {}'.format(icon_in, size, size, icon_out))
Example #28
0
    status = match.text
    return status

# Start in 2 hours
#time.sleep(7200)
url0 = 'https://www.bestbuy.com/site/nintendo-switch-32gb-console-neon-red-neon-blue-joy-con/6364255.p?skuId=6364255' # Red switch
url1 = 'https://www.bestbuy.com/site/nintendo-switch-32gb-console-gray-joy-con/6364253.p?skuId=6364253'
url2 = 'https://www.bestbuy.com/site/nintendo-switch-animal-crossing-new-horizons-edition-32gb-console-multi/6401728.p?skuId=6401728'

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36'}
counter = 0
status_list = []  # Red, Black, Green color of switch

while True:
    counter += 1
    status_list = [status(url0, headers), status(url1, headers), status(url2, headers)]  #[Sold out, Sold out, Add to Cart] could be one of the examples
    time.sleep(1)
    print(datetime.now())
    body = "Red is {0}, Black is {1}, Green is {2}".format(status_list[0], status_list[1], status_list[2]) # Sold Out, Add to Cart, Check Stores
    print(body)

    print('Number of visit: {0}\n'.format(counter))

    if 'Add to Cart' in status_list:
        SendMail.sentmail()
        print("Calling you now....\n")
        call.call()

    time.sleep(13)
Example #29
0
def handleStop(toy, env, store):
    if type(toy.toy) == str:
        raise errors.StopContinuation(toy.toy, env, store)
    raise errors.StopContinuation(call(toy.toy, func("asdasd", "asdasd")), env,
                                  store)
Example #30
0
def dial(number=None):
    call.call(number)
    # Give a couple of seconds for the script to run
    # before respondng
    sleep(2)
    return "Calling %s " % (number)
Example #31
0
def on_message(client, userdata, msg):
    print('Recieved message!')
    conn = psycopg2.connect(database="sensor_data2", user="******", password="******", host="127.0.0.1", port="5432")
    cur = conn.cursor()

    data=msg.payload.decode("utf-8")
    data=json.loads(data)
    print(data)    



    today = date.today()
    d = today.strftime("%d/%m/%Y")

    print(type(d))
    file1 = open("data.txt","r")  
    user_id = file1.read() 
    file1.close() 

    cur.execute("INSERT INTO HEALTH_DATA2 (USER_ID,HR,BLOOD_OXYGEN_LEVEL,TEMPERATURE,BP_SYSTOLIC,BP_DIASTOLIC,DATE_TIME) \
      VALUES ({},{},{},{},{},{},{})".format(user_id,data['hr'],data['blood_oxygen_level'],data['body_temperature'],data['blood_pressure_systolic'],data['blood_pressure_diastolic'],d));    

    condition = ""
    to_number = "+919057014880"     #modify this to get nearest ambulance number
    
    conn2 = psycopg2.connect(database="User_Data2", user="******", password="******", host="127.0.0.1", port="5432")
    cur2 = conn.cursor()
    cur2.execute("SELECT * from User_Data2 where USER_ID={}".format(user_id))
    rows = cur2.fetchall()
    user_age = rows[0]['AGE']
    user_name = rows[0]['NAME']
    call_needed = False

    if data['hr']>=(220-user_age):
        condition = "Tachycardia"
        call_needed = True 
    elif data['hr']<40:
        condition = "Bradycardia"
        call_needed = True
    elif data['blood_oxygen_level']<0.6:
        condition = "Hypoxemia"
        call_needed = True
    elif data['body temperature']<35:
        condition = "Hypothermia"
        call_needed = True
    elif data['body temperature']>42:
        condition = "Hyperthermia"
        call_needed = True
    elif data['blood_pressure_systolic']<90 or data['blood_pressure_diastolic']<60:
        condition = "Hypotension"
        call_needed = True
    elif data['blood_pressure_systolic']>140 or data['blood_pressure_diastolic']<90:
        condition = "Hypertension"
        call_needed = True
    if call_needed:
        location = ""           #find location
        message = "Alert! User {} is suffering from {} at location {}".format(user_name,condition,location)
        call(to_number,message)
    
    conn.commit()
    conn.close()
    print('Insertion Complete!')
    
    file1 = open("data.txt","w")  
    file1.write(str(int(user_id)+1)) 
    file1.close()