コード例 #1
0
    def __init__(self):
        self.resourceName = 'remoteconnection'

        # Hardcode some paths until we know how to pass our
        # own custom config options to our plugin
        pathToConnModule = '/home/scott/projects/Cosmology/web-hpc-manager/src/python/webserver'
        self.mappingFilePath = '/opt/apache-2.4.7/pv-mapping-file/mapping.txt'

        try :
            sys.path.insert(0, pathToConnModule)
            rcm = __import__('RemoteConnection')
            self.remoteConnMgr = rcm.RemoteConnectionManager()
            self.launcherModule = __import__('SecureRemoteLauncher')
        except Exception as inst :
            print "ERROR: remote connections will not work, exception encountered import module"
            print inst

        Resource.__init__(self)

        self.currentJobsMap = {}

        self.route('POST', ('connect',), self.secureConnect)
        self.route('POST', ('tunnellaunch',), self.sshTunnelLaunch)
        self.route('POST', ('jobschedule',), self.scheduleJob)
        self.route('POST', ('jobstatus',), self.checkJobStatus)
        self.route('POST', ('jobcleanup',), self.cleanupJob)
        self.route('GET', ('create',), self.createConnection)
        self.route('GET', ('command',), self.sendShellCommand)
        self.route('GET', ('disconnect',), self.disconnect)
コード例 #2
0
    def __init__(self):
        Resource.__init__(self)

        #self.route('POST', ('outputs',), self.testOutputs)
        self.route('POST', ('stream', ), self.testStream)
        self.route('POST', ('stream_callback', ), self.streamUpload)
        self.route('POST', ('fetch_parent', ), self.testFetchParent)
コード例 #3
0
ファイル: __init__.py プロジェクト: zachmullen/docker_test
    def __init__(self):
        Resource.__init__(self)

        #self.route('POST', ('outputs',), self.testOutputs)
        self.route('POST', ('stream',), self.testStream)
        self.route('POST', ('stream_callback',), self.streamUpload)
        self.route('POST', ('fetch_parent',), self.testFetchParent)
コード例 #4
0
    def testListCLI(self):
        """
        Test that we can list clis, get help for each, and get the xml spec for
        each.
        """
        from girder.plugins.slicer_cli_web import rest_slicer_cli
        from girder.api.rest import Resource

        restResource = Resource()
        cli_args = ('--list_cli', )
        cli_list = self._runTest(cli_args, contains=['"NucleiDetection"'])
        cli_list = json.loads(cli_list)
        self.assertIn('NucleiDetection', cli_list)
        for cli in cli_list:
            cli_args = (cli, '--help')
            # Each cli's help must mention usage, its own name, and that you
            # can output xml
            self._runTest(cli_args, contains=['usage:', cli, '--xml'])
            cli_args = (cli, '--xml')
            # The xml output needs to have a tile and an executable tag
            xml = self._runTest(cli_args,
                                contains=[
                                    '<executable>', '<title>', '</executable>',
                                    '</title>'
                                ])
            if '<' in xml:
                xml = xml[xml.index('<'):]
            try:
                rest_slicer_cli.genHandlerToRunDockerCLI(
                    'dockerimage', os.environ.get('CLI_CWD'), xml,
                    restResource)
            except Exception:
                sys.stderr.write('Failed in generating endpoints for %s' % cli)
                raise
コード例 #5
0
    def load(self, info):
        info['apiRoot'].configuration = Configuration()

        # Twitter and orcid stuff
        info['apiRoot'].user.route('GET', (':id', 'orcid'), get_orcid)
        info['apiRoot'].user.route('POST', (':id', 'orcid'), set_orcid)
        info['apiRoot'].user.route('GET', (':id', 'twitter'), get_twitter)
        info['apiRoot'].user.route('POST', (':id', 'twitter'), set_twitter)

        # Launch a taskflow with a single endpoint
        info['apiRoot'].launch_taskflow = Resource()
        info['apiRoot'].launch_taskflow.route('POST', ('launch', ),
                                              launch_taskflow_endpoint)
コード例 #6
0
    def testRouteSystem(self):
        # Test an empty route handler
        emptyResource = Resource()
        self.assertRaises(GirderException, emptyResource.handleRoute, 'GET',
                          (), {})

        dummy = DummyResource()

        # Bad route should give a useful exception.
        exc = None
        try:
            dummy.handleRoute('GET', (), {})
        except RestException as e:
            exc = e.message
        self.assertEqual(exc, 'No matching route for "GET "')

        # Make sure route ordering is correct; literals before wildcard tokens
        r = dummy.handleRoute('GET', ('literal1', 'foo'), {})
        self.assertEqual(r, {'wc1': 'literal1', 'wc2': 'foo', 'params': {}})

        r = dummy.handleRoute('GET', ('literal1', 'literal2'), {})
        self.assertEqual(r, {'params': {}})

        r = dummy.handleRoute('PATCH', ('guid', 'patchy'), {})
        self.assertEqual(r, {'id': 'guid', 'params': {}})

        # Add a new route with a new method
        dummy.route('DUMMY', (':id', 'dummy'), dummy.handler)
        r = dummy.handleRoute('DUMMY', ('guid', 'dummy'), {})
        self.assertEqual(r, {'id': 'guid', 'params': {}})

        # Test getting the route handler
        self.assertRaises(Exception, dummy.getRouteHandler, 'FOO',
                          (':id', 'dummy'))
        self.assertRaises(Exception, dummy.getRouteHandler, 'DUMMY',
                          (':id', 'foo'))
        registeredHandler = dummy.getRouteHandler('DUMMY', (':id', 'dummy'))
        # The handler method cannot be compared directly with `is`, but its name and behavior can be
        # examined
        self.assertEqual(registeredHandler.__name__, dummy.handler.__name__)
        self.assertEqual(registeredHandler(foo=42), {'foo': 42})

        # Now remove the route
        dummy.removeRoute('DUMMY', (':id', 'dummy'))
        self.assertRaises(RestException, dummy.handleRoute, 'DUMMY',
                          ('guid', 'dummy'), {})
コード例 #7
0
    def __init__(self):
        Resource.__init__(self)

        self.resourceName = 'blur_example'
        self.route('POST', (':id',), self.createBlurImage)