Exemple #1
0
 def __init__(self, userName, startDir, autohostFactory, password, map_file,
              mod_file, engineName, engineVersion, roomName, gameName,
              battlePort, autohostCTLClient):
     threading.Thread.__init__(self)
     self.autohost = autohostFactory
     self.username = autohostFactory.new_autohost()
     self.hostedby = userName
     print(colored('[INFO]', 'green'),
           colored(self.username + ': Autohost account received!', 'white'))
     self.password = password
     self.map_file = map_file
     self.mod_file = mod_file
     self.engineName = engineName
     self.engineVersion = engineVersion
     self.roomName = roomName
     self.gameName = gameName
     self.engineToken = ''.join(
         random.choices(string.ascii_uppercase + string.digits, k=6))
     self.battlePort = battlePort
     self.startDir = startDir
     self.autohostCTL = autohostCTLClient
     self.client = Client(self.battlePort, self.startDir)
     self.unitSync = UnitSync(self.startDir,
                              self.startDir + '/engine/libunitsync.so',
                              self.username)
     self.isLaunched = False
     self.server = ServerLauncher()
     self.hosterMem = {}
     self.deliver = queue.Queue()
Exemple #2
0
    def test_send(self, SenderMockWebSocket, ReceiverMockWebSocket):
        # Set up some clients
        sender = Client(SenderMockWebSocket)
        receiver = Client(ReceiverMockWebSocket)
        message_handler = MessageHandler()
        message_handler.add_client(sender)
        message_handler.add_client(receiver)
        self.assertTrue(len(message_handler.clients) == 2)

        # It sends a message to receiver
        sample_message = Message(receiver_guid=receiver.address,
                                 type="announce",
                                 data="data")
        asyncio.get_event_loop().run_until_complete(
            message_handler.send(sender, sample_message))
        # It called send
        ReceiverMockWebSocket.send.assert_called()

        # It sent the right message
        sent_message = Message.from_json(
            ReceiverMockWebSocket.send.call_args[0][0])
        sent_data = sent_message.data
        sent_type = sent_message.type
        self.assertEqual(sent_data, sample_message.data)
        self.assertEqual(sent_type, sample_message.type)

        # It set the "sender_guid"
        sent_from = sent_message.sender_guid
        self.assertEqual(sent_from, sender.address)
Exemple #3
0
    def __init__(path, rhost, rport, bid):
        self.path = path

        self.client = Client(rhost, rport, bytes(bid, 'utf8'))
        self.client.SetLinkDropHandler(lambda: SimpleBackup.LinkDrop(self))
        self.cs = ChunkPushPullSystem(client, load=False)
        self.ValidCheck()
Exemple #4
0
    def get_client(args, config):
        """Return instantiated client.

        Config will provide global overrides.
        """
        client = Client()
        date = datetime.strftime(datetime.today(), "%Y_%m_%dT%H_%M_%S_%f")

        client.ip = args.remote
        client.jobname = "{0}-{1}-worker".format(client.ip, date)

        if args.user is not None:
            client.user = args.user
            client.is_sudoer = True

        if args.delay_pickup:
            client.delay_pickup = True

        if not config['DEFAULT']['output']:
            if args.output is not None:
                client.output = args.output

        if not config['DEFAULT']['compress']:
            if args.dont_compress:
                client.compress = not client.compress

        cprint(
            "> Establishing secure connection {0}@{1}".format(
                client.user, client.ip), 'blue')
        client.pass_ = getpass.getpass()

        return client
Exemple #5
0
    def test_broadcast(self, SenderMockWebSocket, Receiver1MockWebSocket, Receiver2MockWebSocket):
        # Set up some clients
        sender = Client(SenderMockWebSocket)
        receiver1 = Client(Receiver1MockWebSocket)
        receiver2 = Client(Receiver2MockWebSocket)
        channel = Channel("test_channel")
        channel.add_client(sender)
        channel.add_client(receiver1)
        channel.add_client(receiver2)
        self.assertTrue(len(channel.clients) == 3)

        # It sends a message to each client
        sample_message = Message(
                type = "announce",
                data= "data"
                )
        asyncio.get_event_loop().run_until_complete(
                channel.broadcast(sender, sample_message)
        )
        # It called send
        Receiver1MockWebSocket.send.assert_called()
        Receiver2MockWebSocket.send.assert_called()

        # It sent the right message
        sent_message = Message.from_json(Receiver1MockWebSocket.send.call_args[0][0])
        sent_data = sent_message.data
        sent_type = sent_message.type
        sent_channel_id = sent_message.channel_id
        self.assertEqual(sent_data, sample_message.data)
        self.assertEqual(sent_type, sample_message.type)
        self.assertEqual(sent_channel_id, channel.id)

        # It set the "sender_guid"
        sent_from = sent_message.sender_guid
        self.assertEqual(sent_from, sender.address)
Exemple #6
0
    def run(self):
        dc = DataCollector(self.config.getint('data', 'number-samples'),
                           self.config.getint('general', 'n-gestures'))
        c = Client()
        c.read_stream(self.config.get('openbci', 'stream-type'),
                      dc.data_reader)
        dp = DataPreprocessor()

        var_frame_size = self.config.getint('ml', 'var-frame-size')

        for i in range(self.config.getint('openbci', 'n-channels')):
            dp.running_var(dc.data_x, i, var_frame_size)

        # for i in range(self.config.getint('openbci','n-channels')):
        # 	dp.running_var(dc.data_x, i, 10)

        for i in range(self.config.getint('openbci', 'n-channels')):
            dp.running_var(dc.data_x, i, 20)

        for i in range(self.config.getint('openbci', 'n-channels')):
            dp.running_var(dc.data_x, i, 30)

        for i in range(self.config.getint('openbci', 'n-channels')):
            dp.running_var(dc.data_x, i, 50)

        for i in range(self.config.getint('openbci', 'n-channels')):
            dp.running_var(dc.data_x, i, 70)

        dc.save_data("{}.bin".format(self.env_path + "training/" +
                                     self.options['--outfile']))
Exemple #7
0
class Crawler(object):
    def __init__(self, config_path, seed):
        self.seed = seed
        self.client = Client(config_path, log=True)
        self.client.dump_stats(user=self.seed)
        self.client.extended_stats(user=self.seed)
        self.pp = pprint.PrettyPrinter(depth=6)

    def start_crawler(self):
        pass
Exemple #8
0
 def setup(self):
     self.logger = self._sensor_service.get_logger(__name__)
     self.api_url = self._config[
         'api_url'] + '/events?queue=state_change&types=StateChange'
     self.api_user = self._config['api_state_change_user']
     self.api_password = self._config['api_state_change_password']
     self.trigger_name = 'event.state_change'
     self.trigger_pack = 'icinga2'
     self.trigger_ref = '.'.join([self.trigger_pack, self.trigger_name])
     self.client = Client(self, self.api_url, self.api_user,
                          self.api_password)
     self.logger.info(
         'Icinga2StateChangeSensor initialized with URL: %s User: %s Password: *****',
         self.api_url, self.api_user)
Exemple #9
0
def tweet_list(args):
    if path.isfile(args.tweet_list):
        with open(args.tweet_list, 'r') as f:
            tweets = f.readlines()
        twit = Client(args.config_path, log=False)
        for tweet in tweets:
            stripped = tweet.strip()
            print("[*] Tweeting: %s" % stripped)
            twit.tweet(stripped)
            print("[*] Sleeping for %s seconds" % str(args.int_sleep))
            sleep(args.int_sleep)

    else:
        exit("No such file: %s" % args.tweet_list)
Exemple #10
0
    def api(self) -> Client:
        if self._api is None:
            self._api = Client(
                urljoin(request.url_root,
                        self.cfg.get("api", "Address", fallback="/")))

        return self._api
Exemple #11
0
 def test_init(self):
     # It sets the websocket and address
     sample_websocket = websockets.protocol.WebSocketCommonProtocol(
         host="1")
     client = Client(sample_websocket)
     self.assertEqual(client.websocket, sample_websocket)
     self.assertTrue(uuid.UUID(client.address) != "")
Exemple #12
0
def main():
    with open("./users.json", mode="r") as f:
        data = f.read()

    client = Client(data)

    user = client.get_user(FilterMethods.USERNAME, 'arthurdw')

    if not user:
        print("Couldn't find a user with the username 'arthurdw'")
        return

    print(f"Arthurdw github: {user.github}")

    print('C# programmers: ' +
          ', '.join(user.name for user in client.get_users_by_language('c#')))
 def setUp(self):
     self.target_channel = Channel("target_channel")
     self.target_channel.broadcast = unittest.mock.AsyncMock()
     self.target_channel.send = unittest.mock.AsyncMock()
     self.another_channel = Channel("another_channel")
     self.channels = {
         self.target_channel.id: self.target_channel,
         self.another_channel.id: self.another_channel
     }
     self.sender_mock_socket = MockAsyncIterator(iter([]))
     self.sender = Client(self.sender_mock_socket)
     self.receiver_mock_socket = MockAsyncIterator(iter([]))
     self.receiver = Client(self.receiver_mock_socket)
     self.sample_message = Message(self.sender.address,
                                   self.receiver.address,
                                   self.target_channel.id, "")
Exemple #14
0
    def test_remove_client(self):
        # It removes the client
        remaining_client = Client(websockets.protocol.WebSocketCommonProtocol(host="1"))
        removed_client = Client(websockets.protocol.WebSocketCommonProtocol(host="2"))
        channel = Channel("test-channel")
        channel.add_client(remaining_client)
        channel.add_client(removed_client)
        self.assertTrue(len(channel.clients) == 2)
        
        # It removes a client
        channel.remove_client(removed_client)
        self.assertTrue(len(channel.clients) == 1)

        # It removes the right client
        actual_remaining_client = channel.clients.pop()
        self.assertEqual(remaining_client, actual_remaining_client)
Exemple #15
0
    def run(self):
        if self.options['run-tests']:
            data = self.load("{}.bin".format(self.env_path + "training/" +
                                             self.options['--infile']))
            data = self.discard_transition_samples(data[0], data[1])
            data = list(zip(data[0], data[1]))
            shuffle(data)

            data_x = [r[0][:2] + r[0][-2:] for r in data]
            data_y = [r[1] for r in data]

            for key, c in self.classifiers.items():
                print '============'
                print 'Class.: {}'.format(key)
                c.fit(data_x[:-500], data_y[:-500])
                print 'Score: ' + str(c.score(data_x[-500:], data_y[-500:]))
                print '============\n'

        elif self.options['train']:
            data = self.load("{}.bin".format(self.env_path + "training/" +
                                             self.options['--infile']))
            data = self.discard_transition_samples(data[0], data[1])
            data = list(zip(data[0], data[1]))
            shuffle(data)

            data_x = [r[0][:2] + r[0][-2:] for r in data]
            data_y = [r[1] for r in data]

            clf = self.classifiers[self.options['--clf']]
            clf.fit(data_x[:-500], data_y[:-500])
            joblib.dump(
                clf, "{}_{}.pkl".format(
                    self.env_path + "models/" + self.options['--infile'],
                    self.options['--clf']))
            print 'Saved clf with score: ' + str(
                clf.score(data_x[-500:], data_y[-500:]))

        elif self.options['run']:
            scikit_c = joblib.load("{}.pkl".format(self.env_path + "models/" +
                                                   self.options['--infile']))
            self.clf = SeqClassifier(scikit_c)
            self.window = SimpleWindow(self.q)
            c = Client()
            c.read_stream(self.config.get('openbci', 'stream-type'),
                          self.data_reader)
Exemple #16
0
 def __listen_for_connections(self):
     self.__socket.listen(self.__MAX_HOSTS)
     print('Server initialized')
     while not self.__check_stop():
         try:
             self.__socket.settimeout(1)
             connection, address = self.__socket.accept()
             client = Client(connection, address,
                             self.__requests_dictionary, self.__MAX_PACKAGE,
                             self)
             client.start()
             self.__connected_clients.append(client)
         except socket.timeout:
             pass
         except Exception as e:
             print("unexpected error server will be stopped" + str(e))
             self.__stopped = True
     self.__close_server()
Exemple #17
0
    def test_remove_client(self):
        # It removes the client
        remaining_client = Client(
            websockets.protocol.WebSocketCommonProtocol(host="1"))
        removed_client = Client(
            websockets.protocol.WebSocketCommonProtocol(host="2"))
        message_handler = MessageHandler()
        message_handler.add_client(remaining_client)
        message_handler.add_client(removed_client)
        self.assertTrue(len(message_handler.clients) == 2)

        # It removes a client
        message_handler.remove_client(removed_client)
        self.assertTrue(len(message_handler.clients) == 1)

        # It removes the right client
        actual_remaining_client = message_handler.clients.pop()
        self.assertEqual(remaining_client, actual_remaining_client)
Exemple #18
0
    def test_add_client(self):
        # It adds the client and assigns a uuid address
        test_client = Client(websockets.protocol.WebSocketCommonProtocol())
        message_handler = MessageHandler()
        message_handler.add_client(test_client)
        self.assertTrue(len(message_handler.clients) == 1)

        client = message_handler.clients.pop()
        self.assertEqual(client, test_client)
Exemple #19
0
    def test_add_client(self):
        # It adds the client and assigns a uuid address
        test_client = Client(websockets.protocol.WebSocketCommonProtocol())
        channel = Channel("test-channel")
        channel.add_client(test_client)
        self.assertTrue(len(channel.clients) == 1)

        client = channel.clients.pop()
        self.assertEqual(client, test_client)
 def setup(self):
   self.logger = self._sensor_service.get_logger(__name__)
   self.api_url = self._config['api_url'] + '/events?queue=state_change&types=StateChange'
   self.api_user = self._config['api_state_change_user']
   self.api_password = self._config['api_state_change_password']
   self.trigger_name = 'event.state_change'
   self.trigger_pack = 'icinga2'
   self.trigger_ref = '.'.join([self.trigger_pack, self.trigger_name])
   self.client = Client(self, self.api_url, self.api_user, self.api_password)
   self.logger.info('Icinga2StateChangeSensor initialized with URL: %s User: %s Password: *****', self.api_url, self.api_user)
Exemple #21
0
 def __init__(self, config_path, log=True):
     self.config_path = config_path
     self.client = Client(config_path, log=log)
     self.reload_config()
     self.tweets = self.load_tweets()
     self.running = True
     self.start_time = datetime.now()
     self.total_retweets = 0
     self.total_tweets = 0
     self.total_follows = 0
     self.total_favourites = 0
     self.uptime = ''
     self.last_tweet_user = ''
     self.last_tweet_text = ''
     self.log_handler = self.LogHandler()
     signal(SIGUSR1, self.catch_signal)
     if log:
         logging.basicConfig(level=self.client.log_level,
             format='[%(levelname)s] (%(threadName)-10s) %(message)s'
         )
Exemple #22
0
class Icinga2StateChangeSensor(Sensor):
    def setup(self):
        self.logger = self._sensor_service.get_logger(__name__)
        self.api_url = self._config[
            'api_url'] + '/events?queue=state_change&types=StateChange'
        self.api_user = self._config['api_state_change_user']
        self.api_password = self._config['api_state_change_password']
        self.trigger_name = 'event.state_change'
        self.trigger_pack = 'icinga2'
        self.trigger_ref = '.'.join([self.trigger_pack, self.trigger_name])
        self.client = Client(self, self.api_url, self.api_user,
                             self.api_password)
        self.logger.info(
            'Icinga2StateChangeSensor initialized with URL: %s User: %s Password: *****',
            self.api_url, self.api_user)

    def process_event(self, event):
        self.logger.info('Processing event: %s', event)
        payload = {}
        payload['service'] = event['service']
        payload['host'] = event['host']
        payload['state'] = event['state']
        payload['state_type'] = event['state_type']
        payload['type'] = event['type']
        payload['check_result'] = event['check_result']
        self.dispatch_trigger(payload)

    def run(self):
        self.logger.info('Setting up API connection params.')
        self.client.setup_connection()
        self.logger.info('Starting connection to API endpoint.')
        self.client.start()

    def cleanup(self):
        self.client.abort_session()

    def add_trigger(self, trigger):
        pass

    def update_trigger(self, trigger):
        pass

    def remove_trigger(self, trigger):
        self.client.abort_session()

    def dispatch_trigger(self, payload):
        self.logger.info('Dispatching trigger: %s', self.trigger_ref)
        self._sensor_service.dispatch(self.trigger_ref, payload)
class Icinga2StateChangeSensor(Sensor):
    def setup(self):
        self.logger = self._sensor_service.get_logger(__name__)
        self.api_url = self._config['api_url'] + '/events?queue=state_change&types=StateChange'
        self.api_user = self._config['api_state_change_user']
        self.api_password = self._config['api_state_change_password']
        self.trigger_name = 'event.state_change'
        self.trigger_pack = 'icinga2'
        self.trigger_ref = '.'.join([self.trigger_pack, self.trigger_name])
        self.client = Client(self, self.api_url, self.api_user, self.api_password)
        self.logger.info(
            'Icinga2StateChangeSensor initialized with URL: %s User: %s Password: *****',
            self.api_url, self.api_user)

    def process_event(self, event):
        self.logger.info('Processing event: %s', event)
        payload = {}
        payload['service'] = event['service']
        payload['host'] = event['host']
        payload['state'] = event['state']
        payload['state_type'] = event['state_type']
        payload['type'] = event['type']
        payload['check_result'] = event['check_result']
        self.dispatch_trigger(payload)

    def run(self):
        self.logger.info('Setting up API connection params.')
        self.client.setup_connection()
        self.logger.info('Starting connection to API endpoint.')
        self.client.start()

    def cleanup(self):
        self.client.abort_session()

    def add_trigger(self, trigger):
        pass

    def update_trigger(self, trigger):
        pass

    def remove_trigger(self, trigger):
        self.client.abort_session()

    def dispatch_trigger(self, payload):
        self.logger.info('Dispatching trigger: %s', self.trigger_ref)
        self._sensor_service.dispatch(self.trigger_ref, payload)
Exemple #24
0
async def dispatch(websocket, path):
    client = Client(websocket)
    print("New client: " + client.address, flush=True)
    try:
        async for json_message in websocket:
            message = Message.from_json(json_message)
            if (message.type == "announce"):
                message_handler.add_client(client)
                await message_handler.broadcast(client, message)
            elif (message.type in ["offer","answer","ice"]):
                await message_handler.send(client, message)
    finally:
        message_handler.remove_client(client)

        # broadcast the departure
        message = Message(type = "hangup")
        await message_handler.broadcast(client, message)
        print("Client " + client.address + " left", flush=True)
Exemple #25
0
def main():
    print('--- Data Miner by Trivernis ---')
    print('(Please respect the api providers)')
    print('-------------------------------')
    args = parse_arguments()
    interval = parse_duration(args.interval)
    if interval.total_seconds() == 0:
        print(
            "[-] The interval must be greater than one second (this is not a dos tool)."
        )
        exit(1)
    if args.tor:
        client = TorClient(password=args.tor_password)
    else:
        client = Client()
    if not os.path.exists(args.output_dir):
        os.mkdir(args.output_dir)
    mapping = {}
    mapping_file = '%s/mapping.json' % args.output_dir
    if os.path.exists(mapping_file):
        with open(mapping_file, 'r') as mf:
            try:
                mapping = json.load(mf)
            except Exception as e:
                print(e)
    dirs = []
    for url in args.url:
        folder_name = get_folder_name(url)
        mapping[url] = folder_name
        dirs.append(folder_name)
    with open(mapping_file, 'w') as mf:
        json.dump(mapping, mf, indent='  ')
    body = None
    if args.body:
        body = open(args.body, 'rb')
    fm = FileManager(args.output_dir, dirs, compress=args.compress)
    print('[ ] Starting request loop...')
    request_loop(client,
                 args.url,
                 fm,
                 args.method,
                 not args.no_verify,
                 int(interval.total_seconds()),
                 body=body)
Exemple #26
0
    async def handle_connection(self, websocket: iter, path: str):
        client = Client(websocket)
        print("New client: " + client.address, flush=True)
        channel = None
        try:
            async for json_message in websocket:
                message = Message.from_json(json_message)
                if message.type == "create_channel":
                    new_channel = Channel(message.data["name"])
                    self.channels[new_channel.id] = new_channel
                    ack = Message(type="ack",
                                  data={"channel_id": new_channel.id})
                    await websocket.send(ack.to_json())
                    continue

                channel_id = message.channel_id
                if channel_id in self.channels.keys():
                    channel = self.channels[channel_id]
                else:
                    message = Message(type="error")
                    await websocket.send(message.to_json())
                    await websocket.close()
                    break

                if (message.type in ["announce"]):
                    channel.add_client(client)
                    await channel.broadcast(client, message)
                elif (message.type in ["offer", "answer", "ice"]):
                    await channel.send(client, message)
                elif (message.type in ["name"]):
                    await channel.broadcast(client, message)

        finally:
            if channel:
                channel.remove_client(client)

                # broadcast the departure
                message = Message(type="hangup")
                await channel.broadcast(client, message)
            print("Client " + client.address + " left", flush=True)
Exemple #27
0
def tweet(args):
    twit = Client(args.config_path, log=True)
    stripped = args.tweet.strip()
    print("[*] Tweeting: %s" % stripped)
    twit.tweet(stripped)
Exemple #28
0
import time
import urllib.request
import urllib.error
import urllib

from lib.client import Client, get_api_path

client = Client(access_key='ACCESS_KEY', secret_key='SECRET_KEY')

#demo of GET APIs

#get member info
print ("memo")
print (client.get(get_api_path('members'),None, True))

#get markets
markets =  client.get(get_api_path('markets'))
print ("markets:", markets)

#get tickers of each market
print ("tickers in markets")
print (client.get(get_api_path('tickers') % 'btscny'))

for market in markets:
    print(str(market["id"]))
    print (client.get(get_api_path('tickers') % market["id"]))

print (client.get(get_api_path('orders'), {'market':'daocny'}, True))

#get orders of each market
#market should be specified in params
Exemple #29
0
import sys, os
sys.path.append(os.path.abspath(".."))

from haigha.connection import Connection
from lib.client import Client
from lib.task import Task

conn = Connection()
client = Client(conn=conn)

task = Task("run_test", "test message")
client.submit_task(task)
    self.logger.info('Setting up API connection params.')
    self.client.setup_connection()
    self.logger.info('Starting connection to API endpoint.')
    self.client.start()

  def cleanup(self):
    self.client.abort_session()

  def add_trigger(self, trigger):
    pass

  def update_trigger(self, trigger):
    pass

  def remove_trigger(self, trigger):
    self.client.abort_session()

  def dispatch_trigger(self, payload):
    self.logger.info('Dispatching trigger: %s', self.trigger_ref)
    self._sensor_service.dispatch(self.trigger_ref, payload)

if __name__ == '__main__':

  STREAM_URL = 'https://icinga2dev.stack.qadev.corp:5665/v1/events?queue=test&types=StateChange'
  USER = '******'
  PASS = '******'

  client = Client(None, STREAM_URL, USER, PASS)
  client.setup_connection()
  client.start()
Exemple #31
0
 def __init__(self, server, token):
     Client.__init__(self, server, token, 'Eventful')
Exemple #32
0
 def __init__(self):
     Client.__init__(self, CLIENT_GM['url'], CLIENT_GM['token'])
Exemple #33
0
 def __init__(self, server):
     Client.__init__(self, server, '', 'Universe')
Exemple #34
0
 def __init__(self, config_path, seed):
     self.seed = seed
     self.client = Client(config_path, log=True)
     self.client.dump_stats(user=self.seed)
     self.client.extended_stats(user=self.seed)
     self.pp = pprint.PrettyPrinter(depth=6)
import time
import urllib2
from lib.client import Client, get_api_path

client = Client(access_key="your access key", secret_key="your secret key")

# demo of GET APIs

# get member info
print client.get(get_api_path("members"))

# get markets
markets = client.get(get_api_path("markets"))
print "markets:", markets

# get tickers of each market
# market should be specified in url
print
print "tickers in markets"
for market in markets:
    print client.get(get_api_path("tickers") % market["id"])

# get orders of each market
# market should be specified in params
print
print "orders in markets"
for market in markets:
    print client.get(get_api_path("orders"), {"market": market["id"]})

# get order book
print client.get(get_api_path("order_book"), params={"market": "btccny"})
Exemple #36
0
    def client(self):
        client_instance = Client()
        client_instance.set_config(self.config)
        client_instance.set_redis_connection(self.get_redis_connection())

        return client_instance
Exemple #37
0
def retweet(args):
    twit = Client(args.config_path, log=True)
    twit.retweet_loop(args.retweet_search)
Exemple #38
0
def user_lookup(args):
    twit = Client(args.config_path, log=True)
    twit.dump_stats(user=args.user_lookup)
    twit.extended_stats(user=args.user_lookup)
 def __init__(self, server, token):
     Client.__init__(self, server, token, 'Brown Paper Tickets')
Exemple #40
0
def get_my_stats(args):
    twit = Client(args.config_path, log=True)
    twit.dump_stats()
Exemple #41
0
import time
import urllib2
from lib.client import Client, get_api_path

client = Client(access_key='your access key', secret_key='your secret key')

#demo of GET APIs

#get member info
print client.get(get_api_path('members'))

#get markets
markets =  client.get(get_api_path('markets'))
print "markets:", markets

#get tickers of each market
#market should be specified in url
print 
print "tickers in markets"
for market in markets:
    print client.get(get_api_path('tickers') % market['id'])

#get orders of each market
#market should be specified in params
print 
print "orders in markets"
for market in markets:
    print client.get(get_api_path('orders'), {'market': market['id']})

#get order book
print client.get(get_api_path('order_book'), params={'market': 'btcaud'})
Exemple #42
0
import time
import urllib2
from lib.client import Client, get_api_path

client = Client(access_key='', secret_key='')

#demo of GET APIs

#get member info
print client.get(get_api_path('members'))

#get markets
markets =  client.get(get_api_path('markets'))
print "markets:", markets

#get tickers of each market
#market should be specified in url
print 
print "tickers in markets"
for market in markets:
    print client.get(get_api_path('tickers') % market['id'])

#get orders of each market
#market should be specified in params
print 
print "orders in markets"
for market in markets:
    print client.get(get_api_path('orders'), {'market': market['id']})

#get order book
print client.get(get_api_path('order_book'), params={'market': 'btccny'})
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
    :copyright: (c) 2015 by Halfmoon Labs, Inc.
    :license: MIT, see LICENSE for more details.
"""

from lib.client import Client

ONENAME_API_ID = ''
ONENAME_API_SECRET = ''

if __name__ == '__main__':

    c = Client(ONENAME_API_ID, ONENAME_API_SECRET)

    print c.get_user('albertwenger')