common.services.prompt package

Submodules

common.services.prompt.HtmlAWEprompt module

Module with the web based awe prompt

class common.services.prompt.HtmlAWEprompt.HtmlAWE(args)

Bases: common.services.general.HtmlBase.HtmlBase

class for generating html from the template file AWEprompt.html.tmpl

SessionLifeTime = datetime.timedelta(0, 7200)
allow_anonymous = True
authorize()

test the username and password

checkUserDir()

make a directory for this user (if not exist)

classmethod cleanupSessions()

cleanup old obsolete User Sessions data

classmethod cleanupUserSession(global_data)

remove the user dir

completeCommand(phrase)

user hit tab, use rlcompleter to give back all possible commands

doCommand()

run the user given command

getHtml()

generate html

getUserDir(session_id, username)

return the directory name of the user

initialize()

initialization that must be done after __init__

initialize_global_data()

intialize the global data dict

users_dir = 'awe_prompt_users'
common.services.prompt.HtmlAWEprompt.getcommonstart(seq)

get the common part of all strings in seq

common.services.prompt.HtmlAWEprompt.splitCommand(command)

find the most right command, using the delims in readline return splitted string

common.services.prompt.myInterpreter module

class common.services.prompt.myInterpreter.ThreadedStdOut

Bases: object

Class simulates the write method of stdout and stores the output in a per thread dictionary

flush()

define a dummy flush method

pop_thread_stdout()

pop the latest output of the given thread

write(data)

this write overrules the standard stdout.write

class common.services.prompt.myInterpreter.myInterpreter

Bases: code.InteractiveInterpreter

Extended InteractiveInterpreter class - keeps a history of all commands - uses a threadsafe stdout

STARTUP_COMMANDS = "\nimport os\nprint('')\nprint('')\nprint(' Welcome to the Astro-WISE Environment ')\nprint('')\nif 'AWEPIPE' in os.environ:\n try:\n newsfile = os.path.join(os.environ['AWEPIPE'], 'astro', 'NEWS')\n for line in open(newsfile).readlines():\n print(line.strip())\n del newsfile\n if 'line' in locals():\n del line\n except IOError as e:\n pass\n\nimport astro\ntag = astro.__tag__.split()\nif len(tag) == 3:\n print('|\tYou are running the %s version' % tag[1])\n\ndel tag\nprint('')\nprint('Importing Astro-WISE packages. Please wait...')\nfrom astro.config.startup import *\nprint('')\nfrom common.config.Environment import Env\nfrom common.config.Profile import profiles\np = profiles.get_current_profile()\nif 'dpu_name' in Env and Env['dpu_name']:\n if p.is_anonymous() :\n print('The Distributed Processing Unit is not available for an anonymous user')\n else :\n print('Distributed Processing Unit: %s' % Env['dpu_name'])\n from astro.recipes.mods.dpu import Processor\n dpu = Processor(Env['dpu_name'])\n print('')\n\nprint('Current profile: ')\nprint('- username : ' + p.username)\nprint('- database : ' + p.dbname)\nprint('- project : ' + p.project)\nprint('')\ndel p, profiles\nfrom common.database.Context import Context\ncontext = Context()\n"
append_history(output)

append output to history

format_output(output)

format the output

initialize()

initialize or re-initialize this instance

runsource(code, show_code=True, show_output=True)

run the given code in the interpretor

setOutput()

pop the output from the current thread

write(data)

write data to output

Module contents