dgquintas / BoincVM

No description has been added.

Clone this repository (size: 1.2 MB): HTTPS / SSH
$ hg clone http://bitbucket.org/dgquintas/boincvm/
commit 156: 82322fb03d90
parent 155: 77f02d757d3b
branch: default
tags: tip
Added tag 0.2.1 for changeset 77f02d757d3b
dgq...@21.1.168.192.in-addr.arpa
4 months ago
BoincVM / HostMain.py
r156:82322fb03d90 40 loc 1.0 KB embed / history / annotate / raw /
#!/bin/env python

from BoincVMController.stomp.StompProtocol import StompProtocolFactory
from BoincVMController.stomp.HostStompEngine import Host 

from twisted.internet import reactor
from ConfigParser import SafeConfigParser

import logging

logging.basicConfig(level=logging.DEBUG, \
    format='%(asctime)s - %(name)s - %(levelname)s: %(message)s', )

def start(config):
  """Start twisted event loop and the fun should begin..."""
  host = config.get('Broker', 'host') 
  port = int(config.get('Broker', 'port'))
  username = config.get('Broker', 'username')
  password = config.get('Broker', 'password')

  hostEngine = lambda: Host(config)
  stompProtocolFactory = StompProtocolFactory(hostEngine, username, password)
  
  reactor.connectTCP(host, port, stompProtocolFactory)
  reactor.run()


if __name__ == '__main__':
  from sys import argv
  if len(argv) < 2:
    print "Usage: %s <config-file>" % argv[0]
    exit(-1)
  else:
    configFile = argv[1]

    config = SafeConfigParser()
    config.read(configFile)

  start(config)