Exemple #1
1
    def run(self):  
        # initialize windows side   
        tosdb.admin_init(self._addr, AINIT_TIMEOUT)   
        tosdb.vinit(root=self._dll_root)

        # create block
        blk = tosdb.VTOSDB_DataBlock(self._addr, BLOCK_SIZE, date_time=True)
        blk.add_items(*(self._symbols))
        blk.add_topics('last')
        if args.vol:
            blk.add_topics('volume')
     
        # generate filename             
        dprfx = _strftime("%Y%m%d", _localtime())
        isec = int(self._intrvl * 60)  
        for s in self._symbols:
            #
            # create GetOnTimeInterval object for each symbol
            # 
            p = self._out_dir + '/' + dprfx + '_' \
                + s.replace('/','-S-').replace('$','-D-').replace('.','-P-') \
                +'_' + _val_type + '_' + str(self._intrvl) + 'min.tosdb'           
            iobj = _Goti.send_to_file(blk, s, p, _TI.vals[isec], isec/10)
            print(repr(iobj), file=_stderr)
            self._iobjs.append(iobj)

        for i in self._iobjs:
            if i:
                i.join()

        while(True): # why??
            _sleep(10)
Exemple #2
0
    def run(self):
        # initialize windows side
        tosdb.admin_init(self._addr, AINIT_TIMEOUT)
        tosdb.vinit(root=self._dll_root)

        # create block
        blk = tosdb.VTOSDB_DataBlock(self._addr, BLOCK_SIZE, date_time=True)
        blk.add_items(*(self._symbols))
        blk.add_topics('last')
        if args.vol:
            blk.add_topics('volume')

        # generate filename
        dprfx = _strftime("%Y%m%d", _localtime())
        isec = int(self._intrvl * 60)
        for s in self._symbols:
            #
            # create GetOnTimeInterval object for each symbol
            #
            p = self._out_dir + '/' + dprfx + '_' + \
                    s.replace('/','-S-').replace('$','-D-').replace('.','-P-') + \
                    '_' + _val_type + '_' + str(self._intrvl) + 'min.tosdb'
            iobj = _Goti.send_to_file(blk, s, p, _TI.vals[isec], isec / 10)
            print(repr(iobj), file=_stderr)
            self._iobjs.append(iobj)

        for i in self._iobjs:
            if i:
                i.join()

        while (True):
            _sleep(10)
def init():
    global vaddr

    print()
    if args.path:
        print('+ lib path:', args.path)
    elif args.root:
        print('+ lib root:', args.root)
    else:
        print(
            'error: tosdb_test.py requires a --root or --path arg for library')
        return False

    if args.virtual:
        raw = args.virtual.split(' ')
        try:
            v = ((raw[0], int(raw[1])), )
        except IndexError:
            print("usage: tosdb_test --virtual 'address port [timeout]'",
                  file=_stderr)
            return False
        vaddr = v[0]
        v += (int(raw[2]), ) if len(raw) > 2 else ()
        v = v[:1] + (args.auth, ) + v[1:]
        try:
            tosdb.admin_init(*v)
            print('+ admin_init successful')
        except Exception as e:
            print('- admin_init failed:', str(e))
            return False
        try:
            res = tosdb.vinit(dllpath=args.path, root=args.root)
            print('+ vinit successful')
        except Exception as e:
            print('- vinit failed:', str(e))
            return False
    else:
        if _system() not in ["Windows", "windows", "WINDOWS"]:
            print("error: can only run '--virtual' on non Windows systems")
            return False
        try:
            res = tosdb.init(dllpath=args.path, root=args.root)
            print('+ init successful')
        except Exception as e:
            print('- init failed:', str(e))
            return False

    print()
    return True
Exemple #4
0
def init():
    global vaddr

    print()
    if args.path:
        print("+ lib path:", args.path)
    elif args.root:
        print("+ lib root:", args.root)
    else:
        print("error: tosdb_test.py requires a --root or --path arg for library")
        return False

    if args.virtual:
        raw = args.virtual.split(" ")
        try:
            v = ((raw[0], int(raw[1])),)
        except IndexError:
            print("usage: tosdb_test --virtual 'address port [timeout]'", file=_stderr)
            return False
        vaddr = v[0]
        v += (int(raw[2]),) if len(raw) > 2 else ()
        if args.auth:
            v = v[:2] + (args.auth,) + v[2:]
        try:
            tosdb.admin_init(*v)
            print("+ admin_init successful")
        except Exception as e:
            print("- admin_init failed:", str(e))
            return False
        try:
            res = tosdb.vinit(dllpath=args.path, root=args.root)
            print("+ vinit successful")
        except Exception as e:
            print("- vinit failed:", str(e))
            return False
    else:
        if _system() not in ["Windows", "windows", "WINDOWS"]:
            print("error: can only run '--virtual' on non Windows systems")
            return False
        try:
            res = tosdb.init(dllpath=args.path, root=args.root)
            print("+ init successful")
        except Exception as e:
            print("- init failed:", str(e))
            return False

    print()
    return True
Exemple #5
0
    parser.add_argument('errorfile', type=str, help = 'path of error file')
    parser.add_argument('interval', type=int, help="interval size in seconds")
    parser.add_argument('--ohlc', action="store_true", 
                        help="use open/high/low/close instead of close")
    parser.add_argument('--vol', action="store_true", help="use volume")
    parser.add_argument('symbols', nargs='*', help="symbols to pull")
    args = parser.parse_args()

    addr_parts = args.addr.split(' ')
    addr = (addr_parts[0],int(addr_parts[1]))
    
    if args.ohlc:
        itype = 'OHLCV' if args.vol else 'OHLC'
    else:
        itype = 'CV' if args.vol else 'C'

    if not args.path and not args.root:
        print("need --root or --path argument", file=_stderr)
        exit(1)

    # connect              
    tosdb.admin_init(addr, password=args.auth, timeout=AINIT_TIMEOUT)   
    tosdb.vinit(args.path, args.root)
    
    MyDaemon(addr, args.auth, args.outdir, args.pidfile, args.errorfile, 
             args.interval, itype, args.symbols).start()




Exemple #6
0
                        help='password to use if authentication required')
    parser.add_argument('outdir', type=str, help='directory to output data to')
    parser.add_argument('pidfile', type=str, help='path of pid file')
    parser.add_argument('errorfile', type=str, help='path of error file')
    parser.add_argument('interval', type=int, help="interval size in seconds")
    parser.add_argument('--ohlc',
                        action="store_true",
                        help="use open/high/low/close instead of close")
    parser.add_argument('--vol', action="store_true", help="use volume")
    parser.add_argument('symbols', nargs='*', help="symbols to pull")
    args = parser.parse_args()

    addr_parts = args.addr.split(' ')
    addr = (addr_parts[0], int(addr_parts[1]))

    if args.ohlc:
        itype = 'OHLCV' if args.vol else 'OHLC'
    else:
        itype = 'CV' if args.vol else 'C'

    if not args.path and not args.root:
        print("need --root or --path argument", file=_stderr)
        exit(1)

    # connect
    tosdb.admin_init(addr, password=args.auth, timeout=AINIT_TIMEOUT)
    tosdb.vinit(args.path, args.root)

    MyDaemon(addr, args.auth, args.outdir, args.pidfile, args.errorfile,
             args.interval, itype, args.symbols).start()