def __init__(self):
     config = loadConfig("config.ini", config=CONFIGDEFAULT)
     self.rungame = config["rungame.run"], config["rungame.path"], config[
         "rungame.args"], config["rungame.wait"]
     self.logger = log()
     self.watch = watch(config)
     self.RPC = Presence(535809971867222036)
     self.RPC.connect()
     self.main()
예제 #2
0
def watch_and_log(program_names, output_name, capture_rate=2):
    results = defaultdict(list)
    for iteration, snapshots in enumerate(watch(set(program_names), capture_rate)):
        for key, value in snapshots:
            results[key].append((iteration, value))

        if iteration % (capture_rate * 10) == 0:
            write_log(results, output_name)
    write_log(results, output_name)
예제 #3
0
def watch_and_log(program_names, output_name, capture_rate=2):
    results = defaultdict(list)
    for iteration, snapshots in enumerate(
            watch(set(program_names), capture_rate)):
        for key, value in snapshots:
            results[key].append((iteration, value))

        if iteration % (capture_rate * 10) == 0:
            write_log(results, output_name)
    write_log(results, output_name)
예제 #4
0
def __main__():
    """
    Monitor MultiNest scan via command line arguments.
    """

    # Make parser for command line arguments

    parser = arg_parser(description="Monitor MultiNest scan")

    parser.add_argument("root", help="Prefix of MultiNest output filenames (root)", type=str)
    parser.add_argument(
        "--tol", dest="tol", help="MultiNest evidence tolerance factor (tol)", type=float, default=0.1, required=False
    )
    parser.add_argument(
        "--maxiter",
        dest="maxiter",
        help="MultiNest maximum number of iterations (maxiter)",
        type=int,
        default=float("inf"),
        required=False,
    )
    parser.add_argument(
        "--watch",
        dest="watch_mode",
        help="Whether to watch rather than snapshot",
        action="store_true",
        default=False,
        required=False,
    )

    # Fetch arguments

    tol = parser.parse_args().tol
    assert tol > 0.0, "tol <= 0: %s" % tol
    maxiter = parser.parse_args().maxiter
    assert maxiter > 0, "maxiter <= 0: %s" % maxiter
    root = parser.parse_args().root
    watch_mode = parser.parse_args().watch_mode

    if watch_mode:
        watch(root, tol, maxiter)
    else:
        print_snapshot(root, tol, maxiter)
예제 #5
0
__author__ = 'yu'

from watch import watch


if __name__ == '__main__':
    watch('sh000001')
예제 #6
0
__author__ = 'yu'

from watch import watch

if __name__ == '__main__':
    watch('sz000776')
예제 #7
0
def to_progress(id=0):
    """
    1. 根据id 进入不同的函数

    """
    if id == 1:  # ----爬取字母列表
        # url = url_head_1 + 'dict/zimu_' + chr(ord('a')) + '_1.html'  # 单个字母测试
        thread = list()
        for a in range(ord('a'), ord('z') + 1):
            url = url_head_1 + '/dict/zimu_' + \
                chr(a) + '_1.html'  # 生成一个字母的首url链接
            path = './datas/txt/' + chr(a) + '.txt'
            t = threading.Thread(target=spider_1,
                                 args=(url, path))  # 进入spider_1
            thread.append(t)
        for i in thread:
            i.start()
        i.join()
        exit()

    elif (id == 2):  # ----搜索词汇
        # spider3.spider3(word)
        pass

    elif (id == 3):  # ----重新搜索词汇详情
        for i in range(ord('a'), ord('a') + 1):
            path1 = './datas/txt/' + chr(i) + '.txt'
            path2 = './datas/json/' + chr(i) + '.json'
            start = time.time()
            spider_2(path1, path2, letter=chr(i), key_word='', start=start)
        print("------------单词爬取保存成功-------------")
        exit()

    elif (id == 4):  # ----继续搜索词汇详情
        a = 'a'
        key_word = 'A bed of roses'
        try:
            with open("./datas/daily/record.txt", 'r') as ff:  # 读取记录
                lines = ff.readlines()
            a, key_word = lines[0].strip(), lines[1].strip()  # 获取上次字母和单词位置
        except:
            to_progress(id=3)
            exit()
        for i in range(ord(a), ord('z') + 1):
            path1 = './datas/txt/' + chr(i) + '.txt'
            path2 = './datas/json/' + chr(i) + '.json'
            start = time.time()
            spider_2(path1,
                     path2,
                     letter=chr(i),
                     key_word=key_word,
                     start=start)
        exit()
    elif (id == 5):
        for i in range(ord('a'), ord('z') + 1):
            path2 = './datas/json/' + chr(i) + '.json'
            in_sql(path2, host, port, user, password, database)
            print("\r  {}   导入成功".format(chr(i)))
        print("------------ mysql 录入成功 -------------")
        exit()
    elif (id == 6):
        for i in range(ord('a'), ord('z') + 1):
            path1 = './datas/json/' + chr(i) + '.json'
            path2 = './watch/json/new_' + chr(i) + '.json'
            watch(path1, path2)
            print("\r  {}   提取成功".format(chr(i)))
        print("------------ 提取完成 -------------")
        exit()

    else:
        exit()
예제 #8
0
__author__ = 'yu'

from watch import watch

if __name__ == '__main__':
    watch('sz002476')
예제 #9
0
def menu(apikey, apisecret, pushover_user, pushover_app, pushbullet_token,
         redis_password):

    import sys
    import time
    import threading
    import os
    from buy import buy
    from sell import sell
    from buysell import buysell
    from balances import balances
    from orderbook import orderbook
    from watch import watch
    from withdraw import withdraw
    from arbitrage import arbitrage
    from trailing import trailing
    from takeprofit import takeprofit
    from stoplosstakeprofit import stoplosstakeprofit
    from trailingtakeprofit import trailingtakeprofit
    from colorama import Fore, Back, Style, init
    init(autoreset=True)

    while True:
        print(30 * '-')
        print(Fore.GREEN + 'P O N T S T R A D E R . C O M')
        print(30 * '-')
        print(Fore.YELLOW + '1. Buy')
        print(Fore.YELLOW + '2. Sell')
        print(Fore.YELLOW + '3. Buy and Sell')
        print(Fore.YELLOW + '4. Balances')
        print(Fore.YELLOW + '5. Orderbook')
        print(Fore.YELLOW + '6. Watch coin')
        print(Fore.YELLOW + '7. Withdraw')
        print(Fore.YELLOW + '8. Arbitrage')
        print(Fore.YELLOW + '9. Trailing Stop Loss (24/7)')
        print(Fore.YELLOW + '10. Take Profit (BETA + 24/7)')
        print(Fore.YELLOW + '11. Stop Loss + Take Profit (BETA + 24/7)')
        print(Fore.YELLOW + '12. Trailing + Take Profit (BETA + 24/7)')
        print(Fore.RED + '13. Exit')
        print(30 * '-')

        try:
            choice = raw_input('Enter your choice [1-13] : ')
            choice = int(choice)
        except:
            print 'Invalid number. Try again...'

        # BUY
        if choice == 1:
            buy(apikey, apisecret, redis_password)

        # SELL
        elif choice == 2:
            sell(apikey, apisecret, redis_password)

        # BUY AND SELL
        elif choice == 3:
            buysell(apikey, apisecret, redis_password)

        # SHOW WALLETS
        elif choice == 4:
            balances(apikey, apisecret, redis_password)

        # OPEN ORDERS
        elif choice == 5:
            orderbook(apikey, apisecret, redis_password)

        # WATCH
        elif choice == 6:
            watch(apikey, apisecret, redis_password)

        # WITHDRAW
        elif choice == 7:
            withdraw(apikey, apisecret)

        # ARBITRAGE
        elif choice == 8:
            arbitrage(redis_password)

        # TRAILING
        elif choice == 9:
            trailing(apikey, apisecret, pushover_user, pushover_app,
                     pushbullet_token, redis_password)

        # TAKE PROFIT
        elif choice == 10:
            takeprofit(apikey, apisecret, pushover_user, pushover_app,
                       pushbullet_token, redis_password)

        # STOP LOSS TAKE PROFIT
        elif choice == 11:
            stoplosstakeprofit(apikey, apisecret, pushover_user, pushover_app,
                               pushbullet_token, redis_password)

        # TRAILING TAKE PROFIT
        elif choice == 12:
            trailingtakeprofit(apikey, apisecret, pushover_user, pushover_app,
                               pushbullet_token, redis_password)

        # EXIT
        elif choice == 13:
            count = threading.activeCount()
            if count > 1:
                threads = threading.enumerate()
                thread_counter = 0
                for t in threading.enumerate():
                    if 'arbitrage' in t.name:
                        pass
                    elif 'Main' in t.name:
                        pass
                    else:
                        thread_counter += 1
                if thread_counter > 0:
                    print(
                        Fore.YELLOW +
                        'WARNING: There are currently {0} active trade(s), are you sure you want to exit?'
                        .format(thread_counter))
                    print(Fore.GREEN + '1. yes')
                    print(Fore.RED + '2. no')
                    try:
                        yes_no = raw_input('Enter your choice [1-2] : ')
                        yes_no = int(yes_no)
                    except:
                        print 'Invalid number... going back to Main Menu'
                    if yes_no == 1:
                        print 'Exiting...'
                        sys.exit()
                    elif yes_no == 2:
                        print 'Good... going back to Main Menu'
                    else:
                        print 'Invalid number... going back to Main Menu'
                else:
                    print 'Exiting...'
                    sys.exit()
            else:
                print 'Exiting...'
                sys.exit()

        # ELSE EXIT
        else:
            print 'Invalid number. Try again...'
예제 #10
0
import dbfer
import watch
import placePnts
import os


# target_dir = os.path.join("/","users", "waltnixon", "Documents", "github", "dbfWatchAndMerge", "rigdata")
# out_csv = os.path.join("/","users", "waltnixon", "Documents", "github", "dbfWatchAndMerge", "rigdata", "out.csv")
target_dir = r"C:\Users\wnixon\Documents\GitHub\dbfWatchAndMerge\rigdata"
output_dir = r"C:\Users\wnixon\Documents\GitHub\dbfWatchAndMerge\output"

print ("target_dir = {0}".format(target_dir))

if watch.watch(target_dir) == 'change':
	for fileType in ['l', 'p']:
		out_csv = os.path.join(output_dir, "out_csv_" + fileType + '.csv')
		
		dbfFiles = dbfer.getAndFilterFiles(target_dir, fileType, "dbf")

		result = dbfer.mergeDbfFiles(dbfFiles)

		clean = dbfer.removeDups(result[0], result[1])

		csvFile = dbfer.writeCSV(clean, out_csv)
		
		placePnts.plot(csvFile)
예제 #11
0
def watch():
    """Watch for any task."""
    import watch
    watch.watch()
예제 #12
0
    cnx = connect(**base)
    lid = insert_launch(cnx)
    obj, sen = Index(), Index()
    stats, top, dl = prepare(cnx, lid, cargs["ngrams"], cargs["test"], obj,
                             sen)
    k = kernel(cargs["kernel"], cargs["sigma"])
    estimate = Estimate()
    estimate.read()

    for mode, (trset, teset) in zip(["objective", "sentiment"], dl):
        svm = SVM(k,
                  c=cargs["c"],
                  tol=cargs["tol"],
                  lpass=cargs["lpass"],
                  liter=cargs["liter"])
        svm = watch(svm, mode, len(trset[0]), estimate, cnx, lid, cargs)
        tr = train(svm, mode, trset[0], trset[1], cnx, lid)
        te = test(svm, mode, teset[0], teset[1])
        svm, ts = flush(svm, mode)
        stats = update(stats, tr, te, ts)

    create_report(cnx, lid, stats, top, cargs)
    insert_index(cnx, lid, "objective", obj)
    insert_index(cnx, lid, "sentiment", sen)
    estimate.train()
    estimate.store()
except:
    delete_launch(cnx, lid)
    raise
finally:
    cnx.close()
예제 #13
0
def main():
    # Check for required version
    major = sys.version_info[0]
    minor = sys.version_info[1]
    micro = sys.version_info[2]

    python_version = f'{major}.{minor}.{micro}'
    version_string = f'mcfunction expand (Version {__version__})'

    if major != 3 or minor < 8:
        print(
            f'You are using Python {python_version}, however mcfunction expand requires Python 3.8+.\nPlease upgrade to a supported version of Python.'
        )
        exit(1)

    # Parse command line arguments
    parser = ArgumentParser(prog='expand',
                            formatter_class=RawDescriptionHelpFormatter,
                            description=version_string)

    parser.add_argument(
        '-w',
        '--watch',
        help='Start watching the current directory for file changes.',
        action='store_true')
    parser.add_argument('-s',
                        '--silent',
                        help='Reduce output generated by watching.',
                        action='store_true')
    parser.add_argument('-v',
                        '--version',
                        help='Show this release\'s version number.',
                        action='version',
                        version=version_string)
    parser.add_argument('filename',
                        help='Path to the file to compile.',
                        default=None,
                        nargs='?')

    args = parser.parse_args()

    # Validate arguments
    if not any((args.filename, args.watch)):
        print('Error: No arguments provided. Type "expand --help" for help.')
        exit(1)

    if args.filename:
        # Check that the file provided is valid
        file_extension = path.splitext(args.filename)[1]
        if file_extension != '.mcfunction':
            print(
                f'Error: Can only compile files with extension \'.mcfunction\'.\nProvided file has extension \'{file_extension}\'.'
            )
            exit(1)

        try:
            f = open(args.filename, 'r')
            f.close()
            del f

        except FileNotFoundError:
            print(f'Error: File \'{args.filename}\' does not exist.')
            exit(1)

        except IOError:
            print(f'Error: File \'{args.filename}\' is not accessible.')
            exit(1)

        # The input is validated, do something with it
        print(f'Compiling {args.filename}...')
        compile_function(args.filename)

    # Watching for file changes
    if args.watch:
        watch(silent=args.silent)
예제 #14
0
__author__ = 'yu'

from watch import watch


if __name__ == '__main__':
    watch('sz399001', 3)