Beispiel #1
0
def get_local_connections():
    """
    Return connections from local configuration files
    """
    # The default cases, read the local or a specific VERGEd
    # configuration file
    if args.config:
        from vergerpc.config import read_config_file
        cfg = read_config_file(args.config)
    else:
        from vergerpc.config import read_default_config
        cfg = read_default_config(None)
    port = int(cfg.get('rpcport', '20102'))
    rpcuser = cfg.get('rpcuser', '')
    connections = []
    if not args.nolocal:
        local_conn = vergerpc.connect_to_local(
        )  # will use read_default_config
        connections.append(local_conn)
    if not args.noremote:
        remote_conn = vergerpc.connect_to_remote(user=rpcuser,
                                                 password=cfg['rpcpassword'],
                                                 host='localhost',
                                                 port=port,
                                                 use_https=False)
        connections.append(remote_conn)
        return connections
Beispiel #2
0
def connect_to_local(filename=None):
    """
    Connect to default verge instance owned by this user, on this machine.

    Returns a :class:`~vergerpc.connection.VERGEConnection` object.

    Arguments:

        - `filename`: Path to a configuration file in a non-standard location (optional)
    """
    from vergerpc.connection import VERGEConnection
    from vergerpc.config import read_default_config

    cfg = read_default_config(filename)
    if cfg is None:
        cfg = {}
    #port = int(cfg.get('rpcport', '18332' if cfg.get('testnet') else '20102'))
    port = int(cfg.get('rpcport', '20102'))
    rpcuser = cfg.get('rpcuser', '')
    rpcpassword = cfg.get('rpcpassword', '')

    return VERGEConnection(rpcuser, rpcpassword, 'localhost', port)
Beispiel #3
0
def connect_to_local(filename=None):
    """
    Connect to default verge instance owned by this user, on this machine.

    Returns a :class:`~vergerpc.connection.VERGEConnection` object.

    Arguments:

        - `filename`: Path to a configuration file in a non-standard location (optional)
    """
    from vergerpc.connection import VERGEConnection
    from vergerpc.config import read_default_config

    cfg = read_default_config(filename)
    if cfg is None:
        cfg = {}
    #port = int(cfg.get('rpcport', '18332' if cfg.get('testnet') else '20102'))
    port = int(cfg.get('rpcport', '20102'))
    rpcuser = cfg.get('rpcuser', '')
    rpcpassword = cfg.get('rpcpassword', '')

    return VERGEConnection(rpcuser, rpcpassword, 'localhost', port)
Beispiel #4
0
parser = argparse.ArgumentParser()
parser.add_argument('--config', help="Specify configuration file")
parser.add_argument('--nolocal', help="Don't use connect_to_local",
                    action='store_true')
parser.add_argument('--noremote', help="Don't use connect_to_remote",
                    action='store_true')
args = parser.parse_args()

if __name__ == "__main__":

    if args.config:
        from vergerpc.config import read_config_file
        cfg = read_config_file(args.config)
    else:
        from vergerpc.config import read_default_config
        cfg = read_default_config(None)
    port = int(cfg.get('rpcport', '20102'))
    rpcuser = cfg.get('rpcuser', '')

    connections = []
    if not args.nolocal:
        local_conn = vergerpc.connect_to_local()  # will use read_default_config
        connections.append(local_conn)
    if not args.noremote:
        remote_conn = vergerpc.connect_to_remote(
                user=rpcuser, password=cfg['rpcpassword'], host='localhost',
                port=port, use_https=False)
        connections.append(remote_conn)

    for conn in connections:
        assert(conn.getinfo().testnet) # don't test on prodnet