Hi All,

I am looking to run something on the OS, and activate this via a form.
I have the methods to execute working, and have tested these, but have
not been able to get the form to call these.

The following is my code:

===========
Method to do the execution:
===========

def startApp(App):
    getVersion = getWebInstalledVersions(web_home)
    installDict = getExecutables()
    executionStatus = {}
    ctlApp = App
    if ctlApp == "DMT" :
        startResponse = "Please run DMT migrations manually"
        print startResponse
    if ctlApp == "PROXY" :
        dirBeforeIPStart = os.getcwd()
        ipDir = web_home + "/" + "integration-" + getVersion
['PROXY_VERSION'] + "/"
        os.chdir(ipDir)
        doThis = "nohup "  "./" + "run.sh" + " &"
        os.chdir(dirBeforeIPStart)
        startResponse = "start " + ctlApp
        print startResponse
    else :
        doThis = installDict[ctlApp] + " start"
        executeThis = os.system(doThis)
        startResponse = "start " + ctlApp
        print startResponse


def stopApp(App):
    getVersion = getWebInstalledVersions(web_home)
    installDict = getExecutables()
    ctlApp=App
    executionStatus = {}
    if ctlApp == "DMT" :
        startResponse = "Please run DMT migrations manually"
        print startResponse
    elif ctlApp == "ROUTER" :
        action = " stop"
        doThis = installDict[ctlApp] + action
        executeThis = os.system(doThis)
        stopResponse = "Killing " + ctlApp
        print stopResponse
    elif ctlApp == "PROXY" :
        doThis = "echo shutdown | telnet localhost 14100 >/dev/null
2>&1 || true"
        stopResponse = "Killing " + ctlApp
    else :
        action = " kill"
        doThis = installDict[ctlApp] + action
        executeThis = os.system(doThis)
        stopResponse = "Killing " + ctlApp
        print stopResponse

def appCtl(App, Action):
    ctlApp = App
    ctlAction = Action
    if ctlAction == "start" :
        startApp(ctlApp)
    elif ctlAction == "stop" :
        stopApp(ctlApp)
    else :
        print "skipping"

==========
Form
==========

class applicationControlForm(ListForm):

    css = [CSSLink(modname="webdeploy", filename="public/css/
applicationControlForm.css")]

    class fields(WidgetsList):
        installDict = getExecutables()
        applicationList = []
        hover_help = True
        for each in installDict:
            if each == "DMT" :
                pass
            else :
                applicationList.append(each)

        controlApplicationOptions = list(enumerate((applicationList)))
        Application = SingleSelectField('Application',
            options=controlApplicationOptions,
            help_text = 'Please select the Application to control.')

        controlActionOptions = list(enumerate(('start', 'kill',
'restart')))
        Action = SingleSelectField(options=controlActionOptions)
        submit_text = 'execute'

create_applicationControlForm = applicationControlForm
("create_applicationControlForm", action='executeForm')


==============
Controller
==============

    #App Control
    @expose('webdeploy.templates.applicationControl')
    @require(predicates.has_permission('control', msg=l_('Only for
users with Control Privilege')))
    def applicationControl(self, **kw):
        """Handle the 'applicationControl' page."""
        tmpl_context.form = create_applicationControlForm
        return dict(page='applicationControl')

    @validate(create_applicationControlForm,
error_handler=applicationControl)
    @require(predicates.has_permission('control', msg=l_('Only for
users with Control Privilege')))
    @expose()
    def executeForm(self, **kw):
        """Handle the 'applicationControl' page."""
        tmpl_context.form = create_applicationControlForm

        flash("Action executed, may take up to 10 seconds to take
effect.")
        redirect("index")

================================

So how do i call this method from the form:

appCtl(App, Action)

?

All the methods above work, the forms work, its just the final bit of
tying the Form and the methods above I need assistance on.

Anyone have any ideas?

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en.

Reply via email to