Ejemplo n.º 1
0
        # Try creating the user..
        print "User did not exist, trying to create user."
        if failed(connection.account(username, password, "", "daneel-ai bot")):
            print "Username / Password incorrect."
            return

        if failed(connection.login(username, password)):
            print "Created username, but still couldn't login :/"
            return

    games = connection.games()
    if failed(games):
        print "Getting the game object failed!"
        return

    cache = Cache(Cache.key(host, games[0], username))
    return connection, cache

def getDataDir():
    if hasattr(sys, "frozen"):
        return os.path.join(installpath, "share", "daneel-ai")
    if "site-packages" in daneel.__file__:
        datadir = os.path.join(os.path.dirname(daneel.__file__), "..", "..", "..", "..", "share", "daneel-ai")
    else:
        datadir = os.path.join(os.path.dirname(daneel.__file__), "..")
    return datadir
   


def createRuleSystem(rulesfile,verbosity,cache,connection):
    global mods
Ejemplo n.º 2
0
def cache(host, username):
    return Cache(Cache.key(host, username),
                 configdir='/tmp/tpclient-pyweb/cache/')
Ejemplo n.º 3
0
             state,
             message="",
             todownload=None,
             total=None,
             amount=None):
    """Callback function used when downloading all game data"""
    pass


def connect(host, port, username, password):
    """Connect function, used by the backend"""
    try:
        connection = Connection(host=host, port=port, debug=False)
    except socket.error, e:
        raise ConnectionError('Unable to connect to the host.')

    if failed(connection.connect()):
        raise ConnectionError('Unable to connect to the host.')

    if failed(connection.login(username, password)):
        raise ConnectionError('Wrong user name or password.')

    cache = Cache(Cache.key(host, username),
                  configdir='/tmp/tpclient-pyweb/cache/')
    return connection, cache


def cache(host, username):
    return Cache(Cache.key(host, username),
                 configdir='/tmp/tpclient-pyweb/cache/')
Ejemplo n.º 4
0
def cache(host, username):
    return Cache(Cache.key(host, username), configdir='/tmp/tpclient-pyweb/cache/')
Ejemplo n.º 5
0
    """Exception used in connect"""
    def __init__(self, value):
        self.value = value

    def __str__(self):
        return str(self.value)

def callback(mode, state, message="", todownload=None, total=None, amount=None):
    """Callback function used when downloading all game data"""
    pass

def connect(host, port, username, password):
    """Connect function, used by the backend"""
    try:
        connection = Connection(host=host, port=port, debug=False)
    except socket.error, e:
        raise ConnectionError('Unable to connect to the host.')

    if failed(connection.connect()):
        raise ConnectionError('Unable to connect to the host.')

    if failed(connection.login(username, password)):
        raise ConnectionError('Wrong user name or password.')

    cache = Cache(Cache.key(host, username), configdir='/tmp/tpclient-pyweb/cache/')
    return connection, cache

def cache(host, username):
    return Cache(Cache.key(host, username), configdir='/tmp/tpclient-pyweb/cache/')

Ejemplo n.º 6
0
def createCache(host, port, username, password, games):
    """Create the initial cache"""
    #print "Cache Key" + Cache.key(host, games, username)+":"+str(port)+"/"
    cache = Cache(Cache.key(host, games[0], username)+":"+str(port)+"/", configdir='/tmp/tpclient-pyweb/cache/')
    
    return cache