def evalcmd(dir_mo):
    end = True
    import readline
    import rlcompleter
    # readline.set_completer(cct.MyCompleter(dir_mo).complete)
    readline.parse_and_bind('tab:complete')
    while end:
        # cmd = (cct.cct_raw_input(" ".join(dir_mo)+": "))
        cmd = (cct.cct_raw_input(": "))
        # cmd = (cct.cct_raw_input(dir_mo.append(":")))
        # if cmd == 'e' or cmd == 'q' or len(cmd) == 0:
        # print cmd,":",len(cmd)
        if cmd == 'e' or cmd == 'q':
            break
        elif len(cmd) == 0:
            continue
        else:
            try:
                if not cmd.find(' =') < 0:
                    exec(cmd)
                else:
                    print eval(cmd)
                print ''
            except Exception, e:
                print e
                        cct.sleep(ct.duration_sleep_time)
                    else:
                        # top_all = pd.DataFrame()
                        cct.sleeprandom(60)
                        time_s = time.time()
                        print "."
                        break
            else:
                raise KeyboardInterrupt("StopTime")
        except (KeyboardInterrupt) as e:
            # try:
            #     st = cct.cct_raw_input(status
            # except (KeyboardInterrupt) as e:
            #     st = ''
            #     pass
            st = cct.cct_raw_input(ct.RawMenuArgmain() % (market_sort_value))

            if len(st) == 0:
                status = False
            elif len(st.split()[0]) == 1 and st.split()[0].isdigit():
                st_l = st.split()
                st = st_l[0]
                if st in ct.Market_sort_idx.keys():
                    market_sort_value = ct.Market_sort_idx[st]
                    market_sort_value_key = eval(market_sort_value + '_key')
                    if len(st_l) > 1 and st_l[1] == 'f':
                        market_sort_value_key = cct.negate_boolean_list(
                            market_sort_value_key)
                else:
                    log.error("market_sort key error:%s" % (st))
                    cct.sleeprandom(5)
Esempio n. 3
0
                #     status = True
                #     num_input = ''
                #     ave = None
                #     code = ''
                # elif len(st) == 6:
                #     status = True
                #     num_input = st
                #     ave = None
                #     code = ''
                # else:
                #     sys.exit(0)
        except (KeyboardInterrupt) as e:
            # print "key"
            print "KeyboardInterrupt:", e

            st = cct.cct_raw_input("status:[go(g),clear(c),quit(q,e)]:")
            if len(st) == 0:
                status = False
            elif st.lower() == 'g' or st.lower() == 'go':
                status = True
                num_input = ''
                ave = None
                code = ''
            elif len(st) == 6:
                status = True
                num_input = st
                ave = None
                code = ''
            elif st.lower() == 'r':
                dir_mo = eval(cct.eval_rule)
                evalcmd(dir_mo)