<commit_before>import sys
import getopt

class WAS:
    def listApplications(self):
        print "list applications"
        print AdminApp.list()

    def restartServer(self):
        print "restarting server"
        if "" != {{cluster}}:
            print AdminTask.updateAppOnCluster('[-ApplicationNames {{applicationName}} -timeout 3600]')
        else:
            print AdminControl.stopServer('{{server}}', '{{node}}')
            print AdminControl.startServer('{{server}}', '{{node}}')

    def startApplication(self):
        print "starting application"
        appManager = AdminControl.queryNames('node={{node}},type=ApplicationManager,process={{server}},*')
        print appManager
        AdminControl.invoke(appManager, 'startApplication', '{{applicationName}}')

    def stopApplication(self):
        print "stopping application"
        appManager = AdminControl.queryNames('node={{node}},type=ApplicationManager,process={{server}},*')
        print appManager
        AdminControl.invoke(appManager, 'stopApplication', '{{applicationName}}')

    def installApplication(self):
        print "installing application"
        pass

    def uninstallApplication(self):
        print "uninstalling application"
        pass

    def isApplicationInstalled(self):
        return AdminApplication.checkIfAppExists('{{applicationName}}')


#-----------------------------------------------------------------
# Main
#-----------------------------------------------------------------

if __name__ == "__main__":
    methods, args = getopt.getopt(sys.argv, 'o:')<commit_msg>deploy script<commit_after>import sys
import getopt
import time


class WAS:
    def listApplications(self):
        print "list applications"
        print AdminApp.list()
        return AdminApplication.listApplications()

    def restartServer(self):
        print "restarting server"
        if "" != {{cluster}}:
            print AdminTask.updateAppOnCluster('[-ApplicationNames {{applicationName}} -timeout 3600]')
        else:
            print AdminControl.stopServer('{{server}}', '{{node}}')
            print AdminControl.startServer('{{server}}', '{{node}}')

    def startApplication(self):
        print "starting application"
        appManager = AdminControl.queryNames('node={{node}},type=ApplicationManager,process={{server}},*')
        print appManager
        AdminControl.invoke(appManager, 'startApplication', '{{applicationName}}')
        #AdminApplication.startApplicationOnCluster("{{applicationName}}", "{{cluster}}")

    def stopApplication(self):
        print "stopping application"
        appManager = AdminControl.queryNames('node={{node}},type=ApplicationManager,process={{server}},*')
        print appManager
        AdminControl.invoke(appManager, 'stopApplication', '{{applicationName}}')
        #AdminApplication.stopApplicationOnCluster("{{applicationName}}", "{{cluster}}")

    def installApplication(self):
        print "installing application: {{applicationName}}"
        serverMapping = 'WebSphere:cluster={{cluster}}'
        if "" != {{contextRoot}}:
            options = ['-distributeApp', '-appname', {{applicationName}}, '-contextroot', '{{contextRoot}}', '-cluster', {{cluster}}, '-server', {{server}}, '-MapModulesToServers', [['.*','.*', serverMapping]], '-MapWebModToVH', [['.*','.*', {{virtualHost}}]]]
        else:
            options = ['-deployws', '-distributeApp', '-appname', {{applicationName}}, '-cluster', {{cluster}}, '-server', {{server}}, '-MapModulesToServers', [['.*','.*', serverMapping]], '-MapWebModToVH', [['.*','.*', {{virtualHost}}]]]
        AdminApp.install('{{packageFile}}', options)
        AdminConfig.save()
        AdminNodeManagement.syncActiveNodes()

        result = AdminApp.isAppReady('{{applicationName}}')
        while result == "false":
            print AdminApp.getDeployStatus('{{applicationName}}')
            time.sleep(5)
            result = AdminApp.isAppReady('{{applicationName}}')
        print "{{applicationName}} installed"

    def uninstallApplication(self):
        print "uninstalling application: {{applicationName}}"
        AdminApp.uninstall('{{applicationName}}')
        AdminConfig.save()
        AdminNodeManagement.syncActiveNodes()

    def isApplicationInstalled(self):
        return AdminApplication.checkIfAppExists('{{applicationName}}')

    def deploy(self):
        if "true" == isApplicationInstalled():
            uninstallApplication()

        installApplication()
        restartServer()


#-----------------------------------------------------------------
# Main
#-----------------------------------------------------------------

if __name__ == "__main__":
    methods, args = getopt.getopt(sys.argv, 'o:')
{'fraction_non_alphanumeric': 0.2027853977632412, 'fraction_numerical': 0.0018991348385735388, 'mean_word_length': 2.8474025974025974, 'pattern_counts': {'":': 3, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4654571', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1161, 'n_words': 228}