a guest Aug 12th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- from twisted.internet import defer
- import optparse
- from api import get_jocks_api
- from factories import JocksClientFactory
- from protocols import JocksProtocol
- from twisted.python import log
- def parse_args():
- usage = '''usage : %prog[options]
- Jocks Client provide you a simple and free way to downloads jocks stream from Jocks Server running
- all over the internet! You just need to know on what server you want to log on.
- Run it like that :
- python jocks_client --function=<the_function_you_want_to_use> --args=<the specifications you want to use with the function>
- This command will try to connect on a server located to localhost:11444 as default, you can of course choose the location of the server yourself :
- python jocks_client --host=<address of the server host> --port=<the port the server use to provide jocks> --function=<function> --arg=<args>
- For more informations about the functions to use to manage your jocks stream, see the README file!
- parser = optparse.OptionParser(usage)
- help = 'The host name or ipv4 address of the server'
- parser.add_option('--host', help=help, default='localhost')
- help = 'The port use by the server to provide jocks'
- parser.add_option('--port', help=help, type=int, default=11444)
- help = 'The function you want to use to manage the jocks stream of the server'
- parser.add_option('--function', help=help)
- help = 'The arguments you want to use with the function'
- parser.add_option('--arg', help=help)
- options, args = parser.parse_args()
- if len(args) != 0:
- parser.error('Jocks client do not need any argument from the command line.')
- return options
- def main():
- options = parse_args()
- from twisted.internet import reactor
- def get_jocks(jocks):
- print jocks
- def get_jocks_failed(err):
- print 'Jocks stream download failed.'
- def get_jocks_done(_):
- d = get_jocks_api(options.host, options.port, options.function, options.arg)
- d.addCallbacks(get_jocks, get_jocks_failed)
- print 'You can check the logs if something went wrong during the process.'
- log.startLogging(open('/var/log/jocks_client/client.log', 'w'))
- if __name__ == '__main__':
RAW Paste Data