def get_new_apikey(lcc_server):
USERHOME = os.path.expanduser('<STR_LIT>')<EOL>APIKEYFILE = os.path.join(USERHOME,<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>' % lcc_server.replace(<EOL>'<STR_LIT>',<EOL>'<STR_LIT>'<EOL>).replace(<EOL>'<STR_LIT>',<EOL>'<STR_LIT>'<EOL>))<EOL>url = '<STR_LIT>' % lcc_server<EOL>resp = urlopen(url)<EOL>if resp.code == <NUM_LIT:200>:<EOL><INDENT>respdict = json.loads(resp.read())<EOL><DEDENT>else:<EOL><INDENT>LOGERROR('<STR_LIT>' %<EOL>lcc_server)<EOL>LOGERROR('<STR_LIT>' % resp.status_code)<EOL>return None<EOL><DEDENT>apikey = respdict['<STR_LIT:result>']['<STR_LIT>']<EOL>expires = respdict['<STR_LIT:result>']['<STR_LIT>']<EOL>if not os.path.exists(os.path.dirname(APIKEYFILE)):<EOL><INDENT>os.makedirs(os.path.dirname(APIKEYFILE))<EOL><DEDENT>with open(APIKEYFILE,'<STR_LIT:w>') as outfd:<EOL><INDENT>outfd.write('<STR_LIT>' % (apikey, expires))<EOL><DEDENT>os.chmod(APIKEYFILE, <NUM_LIT>)<EOL>LOGINFO('<STR_LIT>' % (lcc_server,<EOL>expires))<EOL>LOGINFO('<STR_LIT>' % APIKEYFILE)<EOL>return apikey, expires<EOL>
This gets a new API key from the specified LCC-Server.

    NOTE: this only gets an anonymous API key. To get an API key tied to a user
    account (and associated privilege level), see the `import_apikey` function
    below.

    Parameters
    ----------

    lcc_server : str
        The base URL of the LCC-Server from where the API key will be fetched.

    Returns
    -------

    (apikey, expiry) : tuple
        This returns a tuple with the API key and its expiry date.