예제 #1
0
def getLinks(page):
    url = URI(page).toURL()
    conn = url.openConnection()
    isr = InputStreamReader(conn.getInputStream())
    br = BufferedReader(isr)

    kit = HTMLEditorKit()
    doc = kit.createDefaultDocument()
    parser = ParserDelegator()
    callback = doc.getReader(0)
    parser.parse(br, callback, 1)

    iterator = doc.getIterator(HTML.Tag.A)
    while iterator.isValid():
        try:
            attr = iterator.getAttributes()
            src = attr.getAttribute(HTML.Attribute.HREF)
            start = iterator.getStartOffset()
            fini = iterator.getEndOffset()
            length = fini - start
            text = doc.getText(start, length)
            print '%40s -> %s' % (text, src)
        except:
            pass
        iterator.next()
예제 #2
0
def __readWsdlWithIdooxFactory(url, importWsdlDocuments = 1):
    from com.idoox.wsdl.factory import WSDLFactoryImpl
    from com.idoox.wsdl.util import XmlUtil
    from org.idoox.transport import TransportMethod

    wsdlfactoryIdox = WSDLFactoryImpl()
    reader = wsdlfactoryIdox.newWSDLReader()
    if importWsdlDocuments == 1:
        reader.setFeature('javax.wsdl.importDocuments', Boolean.TRUE)
    else:
        reader.setFeature('javax.wsdl.importDocuments', Boolean.FALSE)
    uri = URI(url)
    url = uri.toURL()
    urlStr = url.toString()

    connectionProperties = HashMap(7)
    endpoint = XmlUtil.createEndpoint(None, urlStr)
    connection = endpoint.newConnection(TransportMethod.GET, connectionProperties)
    
    inputMessage = connection.getInputMessage()
    statusCode = inputMessage.getStatusCode()
    endpoint = XmlUtil.checkRedirectedUri(connection, endpoint)
    
    if statusCode >= 400:
        raise WSDLException('INVALID_WSDL', 'Cannot get WSDL from URL ' + str(endpoint.toExternalForm()) + ' (status code ' + str(statusCode) + ')')
        
    wsdlData = XmlHelper.prettyPrintXml(XmlHelper.loadRootElement(inputMessage))
    logger.debug('Got wsdl content:\n', wsdlData)
    definition = reader.readWSDL(urlStr)
    return wsdlData, definition
예제 #3
0
def __readWsdlWithIdooxFactory(url, importWsdlDocuments=1):
    from com.idoox.wsdl.factory import WSDLFactoryImpl
    from com.idoox.wsdl.util import XmlUtil
    from org.idoox.transport import TransportMethod

    wsdlfactoryIdox = WSDLFactoryImpl()
    reader = wsdlfactoryIdox.newWSDLReader()
    if importWsdlDocuments == 1:
        reader.setFeature('javax.wsdl.importDocuments', Boolean.TRUE)
    else:
        reader.setFeature('javax.wsdl.importDocuments', Boolean.FALSE)
    uri = URI(url)
    url = uri.toURL()
    urlStr = url.toString()

    connectionProperties = HashMap(7)
    endpoint = XmlUtil.createEndpoint(None, urlStr)
    connection = endpoint.newConnection(TransportMethod.GET,
                                        connectionProperties)

    inputMessage = connection.getInputMessage()
    statusCode = inputMessage.getStatusCode()
    endpoint = XmlUtil.checkRedirectedUri(connection, endpoint)

    if statusCode >= 400:
        raise WSDLException(
            'INVALID_WSDL',
            'Cannot get WSDL from URL ' + str(endpoint.toExternalForm()) +
            ' (status code ' + str(statusCode) + ')')

    wsdlData = XmlHelper.prettyPrintXml(
        XmlHelper.loadRootElement(inputMessage))
    logger.debug('Got wsdl content:\n', wsdlData)
    definition = reader.readWSDL(urlStr)
    return wsdlData, definition
    def __present__(self, fragment, inheritedState):
        configurationLink = Hyperlink(
            'CONFIGURATION PAGE',
            fragment.subject.world.configuration.subject())
        linkHeader = LinkHeaderBar([configurationLink])

        title = TitleBar('About')

        splash = Image.systemImage('SplashScreen.png')

        desc = NormalText(
            'The Larch Environment was designed and written by Geoffrey French'
        )

        jythonLink = Hyperlink('Jython', URI('http://www.jython.org/'))
        jerichoLink = Hyperlink('Jericho HTML parser',
                                URI('http://jericho.htmlparser.net'))
        salamanderLink = Hyperlink('SVG Salamander',
                                   URI('http://svgsalamander.java.net/'))
        googleFontsLink = Hyperlink('Google Fonts',
                                    URI('http://www.google.com/fonts'))

        jythonAcks = NormalText([
            'The Larch Environment incorporates the ', jythonLink,
            ' interpreter.'
        ])
        libraryAcks = NormalText([
            'Larch incorporates the ', jerichoLink, ', and ', salamanderLink,
            ' libraries.'
        ])
        fontAcks = NormalText([
            'Larch incorporates the following fonts (found at ',
            googleFontsLink, '): ',
            'Arimo (by Steve Matteson), Lora (by Cyreal), Nobile (by Vernon Adams), Noto Sans (by Google), ',
            'Open Sans (by Steve Matteson), PT Serif (by ParaType), and Source Sans Pro (by Paul D. Hunt)'
        ])

        copyright = NormalText('(C) copyright Geoffrey French 2008-2013')

        homePage = Hyperlink('The Larch Environment website',
                             URI('http://www.larchenvironment.com'))

        head = Head([linkHeader, title])
        body = Body([
            splash.padY(20.0).alignHCentre(),
            desc.padY(10.0).alignHCentre(),
            Spacer(0.0, 10.0),
            jythonAcks.pad(25.0, 5.0).alignHLeft(),
            libraryAcks.pad(25.0, 5.0).alignHLeft(),
            fontAcks.pad(25.0, 5.0).alignHLeft(),
            Spacer(0.0, 10.0),
            Row([copyright.alignHLeft(),
                 homePage.alignHRight()]).pad(10.0, 10.0).alignHExpand()
        ])
        return StyleSheet.style(Primitive.editable(False)).applyTo(
            Page([head, body]))
    def __init__(self, url, account, username, password):
        print "Creating Conjur client for '%s', account '%s', user '%s'" % (
            url, account, username)

        authnUri = URI.create("%s/authn/%s/" % (url, account))
        secretsUri = URI.create("%s/secrets/%s/variable" % (url, account))

        endpoints = Endpoints(authnUri, secretsUri)

        self.resourceClient = ResourceClient(username, password, endpoints)
    def replace_tokens(self, resource_type, resource_name, attribute_name, resource_dict):
        """
        Replace the tokens in attribute value with the current value.
        :param resource_type: the resource type (used for logging purposes)
        :param resource_name: the resource name (used for logging purposes)
        :param attribute_name: the attribute name for which to replace tokens
        :param resource_dict: the dictionary to use to lookup and replace the attribute value
        """
        attribute_value = resource_dict[attribute_name]
        if attribute_value is None:
            return
        uri = URI(attribute_value)
        uri_scheme = uri.getScheme()
        if uri_scheme is not None and uri_scheme.startsWith('file'):
            attribute_value = uri.getPath()
        if attribute_value.startswith(self.ORACLE_HOME_TOKEN):
            message = "Replacing {0} in {1} {2} {3} with {4}"
            self._logger.fine(message, self.ORACLE_HOME_TOKEN, resource_type, resource_name, attribute_name,
                              self.get_oracle_home(), class_name=self._class_name, method_name='_replace_tokens')
            resource_dict[attribute_name] = attribute_value.replace(self.ORACLE_HOME_TOKEN,
                                                                    self.get_oracle_home())
        elif attribute_value.startswith(self.WL_HOME_TOKEN):
            message = "Replacing {0} in {1} {2} {3} with {4}"
            self._logger.fine(message, self.WL_HOME_TOKEN, resource_type, resource_name, attribute_name,
                              self.get_wl_home(), class_name=self._class_name, method_name='_replace_tokens')
            resource_dict[attribute_name] = attribute_value.replace(self.WL_HOME_TOKEN, self.get_wl_home())
        elif attribute_value.startswith(self.DOMAIN_HOME_TOKEN):
            message = "Replacing {0} in {1} {2} {3} with {4}"
            self._logger.fine(message, self.DOMAIN_HOME_TOKEN, resource_type, resource_name, attribute_name,
                              self.get_domain_home(), class_name=self._class_name, method_name='_replace_tokens')
            resource_dict[attribute_name] = attribute_value.replace(self.DOMAIN_HOME_TOKEN,
                                                                    self.get_domain_home())
        elif attribute_value.startswith(self.JAVA_HOME_TOKEN):
            message = "Replacing {0} in {1} {2} {3} with {4}"
            self._logger.fine(message, self.JAVA_HOME_TOKEN, resource_type, resource_name, attribute_name,
                              self.get_domain_home(), class_name=self._class_name, method_name='_replace_tokens')
            resource_dict[attribute_name] = attribute_value.replace(self.JAVA_HOME_TOKEN,
                                                                    self.get_java_home())
        elif attribute_value.startswith(self.CURRENT_DIRECTORY_TOKEN):
            cwd = path_utils.fixup_path(os.getcwd())
            message = "Replacing {0} in {1} {2} {3} with {4}"
            self._logger.fine(message, self.CURRENT_DIRECTORY_TOKEN, resource_type, resource_name,
                              attribute_name, cwd, class_name=self._class_name, method_name='_replace_tokens')
            resource_dict[attribute_name] = attribute_value.replace(self.CURRENT_DIRECTORY_TOKEN, cwd)
        elif attribute_value.startswith(self.TEMP_DIRECTORY_TOKEN):
            temp_dir = path_utils.fixup_path(tempfile.gettempdir())
            message = "Replacing {0} in {1} {2} {3} with {4}"
            self._logger.fine(message, self.TEMP_DIRECTORY_TOKEN, resource_type, resource_name, attribute_name,
                              temp_dir, class_name=self._class_name, method_name='_replace_tokens')
            resource_dict[attribute_name] = attribute_value.replace(self.TEMP_DIRECTORY_TOKEN, temp_dir)

        return
def extract_from_uri(model_context, path_value):
    """
    If the MBean path attribute has a URI file scheme, look past the scheme and
    resolve any global tokens.

    :param model_context: current context containing job information
    :param path_value: MBean attribute path
    :return: fully resolved URI path, or the path_value if not a URI scheme
    """
    uri = URI(path_value)
    if uri.getScheme() == 'file':
        return FILE_URI + model_context.replace_token_string(uri.getPath()[1:])
    return path_value
예제 #8
0
 def mouseClicked(self, event):
     if event.source == self.jDocs:
         uri = URI.create("https://github.com/DanNegrea/PyRules")
         if uri and Desktop.isDesktopSupported() and Desktop.getDesktop(
         ).isSupported(Desktop.Action.BROWSE):
             Desktop.getDesktop().browse(uri)
     return
예제 #9
0
 def _open_website(self, url):
     uri = URI(url)
     desktop = None
     if Desktop.isDesktopSupported():
         desktop = Desktop.getDesktop()
     if desktop and desktop.isSupported(Desktop.Action.BROWSE):
         desktop.browse(uri)
예제 #10
0
def submit(request, now=False, block=True,
           broker_uri=None):

    if (broker_uri is None):
        broker_uri = getScanningBrokerUri()

    """Submit an existing ScanRequest to the GDA server.

    See the mscan() docstring for details of `now` and `block`.
    """
    scan_bean = ScanBean(request) # Generates a sensible name for the scan from the request.

    # Throws an exception if we made a bad bean
    json = getEventService().getEventConnectorService().marshal(scan_bean)

    if now:
        raise NotImplementedError()  # TODO: Raise priority.


    submitter = getEventService().createSubmitter(URI(broker_uri), SUBMISSION_QUEUE)

    if block:
        submitter.setTopicName(STATUS_TOPIC)
        submitter.blockingSubmit(scan_bean)
    else:
        submitter.submit(scan_bean)
    def __present_contents__(self, fragment, inheritedState):
        self._incr.onAccess()

        dirPres = self._presentDir()
        note = NotesText([
            'Note: please choose the location of the GraphViz ',
            EmphSpan('bin'), ' directory.'
        ])
        columnContents = [note, dirPres]
        if self._config is not None:
            columnContents.append(self._presentConfig())
        pathContents = Column(columnContents)
        pathSection = Section(SectionHeading2('GraphViz path'), pathContents)

        downloadText = ''
        if self.__isConfigured():
            downloadText = 'GraphViz appears to be installed on this machine and configured. If it does not work correctly, you may need to install it. You can download it from the '
        else:
            downloadText = 'If GraphViz is not installed on this machine, please install it. You can download it from the '

        downloadLink = Hyperlink('GraphViz homepage',
                                 URI('http://www.graphviz.org/'))
        download = NormalText([downloadText, downloadLink, '.'])
        downloadSec = Section(
            SectionHeading2('GraphViz download/installation'), download)

        return Body([pathSection, downloadSec])
예제 #12
0
 def getCapabilities(self):  # -> Capabilities
     try:
         return Capabilities(HashSet([ProtocolRef(URI("SAOP"))]))
     except:
         getReporter().log(Level.SEVERE,
                           "Failed to create capabilities URI", e)
     return None
예제 #13
0
def install(version):
    """ Downloads and installs redis """
    script = []
    script.append(Statements.exec("ensure_netutils_apt"))
    script.append(
        Statements.exec(
            "ensure_cmd_or_install_package_apt make build-essential"))
    script.append(
        Statements.extractTargzAndFlattenIntoDirectory(
            URI.create("http://redis.googlecode.com/files/redis-%s.tar.gz" %
                       version), "/usr/local/src/redis"))
    script.append(
        Statements.exec("(cd /usr/local/src/redis && make && make install)"))
    script.append(Statements.exec("{md} /var/lib/redis"))
    script.append(
        Statements.exec("sed -i 's/^daemonize no/daemonize yes/' "
                        "/usr/local/src/redis/redis.conf"))
    script.append(
        Statements.exec(
            "sed -i 's/^logfile .*/logfile \/var\/log\/redis.log/' "
            "/usr/local/src/redis/redis.conf"))
    script.append(
        Statements.exec("sed -i 's/^dbfilename .*/dbfilename redis.rdb/' "
                        "/usr/local/src/redis/redis.conf"))
    script.append(
        Statements.exec("sed -i 's/^dir .*/dir \/var\/lib\/redis/' "
                        "/usr/local/src/redis/redis.conf"))
    script.append(
        Statements.appendFile("/etc/sysctl.conf",
                              ["vm.overcommit_memory = 1"]))
    script.append(Statements.exec("sysctl vm.overcommit_memory=1"))
    script.append(
        Statements.exec(
            "/usr/local/bin/redis-server /usr/local/src/redis/redis.conf"))
    return script
예제 #14
0
def add_loc_info(self, node, obj):
    """
    Add file location meta information to CPG objects.
    """

    obj.setFile(self.fname)

    if not isinstance(node, ast.AST):
        self.log_with_loc(
            "Expected an AST object but received %s. Not adding location." %
            (type(node)), loglevel="ERROR")
        return

    uri = URI("file://" + self.fname)
    obj.setLocation(PhysicalLocation(uri,
                                     Region(node.lineno,
                                            node.col_offset,
                                            node.end_lineno,
                                            node.end_col_offset)
                                     )
                    )
    obj.setCode(self.sourcecode.get_snippet(node.lineno,
                                            node.col_offset,
                                            node.end_lineno,
                                            node.end_col_offset)
                )
예제 #15
0
 def __init__(self, program):
     url = "https://yeswehack.com/programs/{}".format(program.slug)
     btn = JButton("Open in browser")
     btn.addActionListener(
         CallbackActionListener(lambda _: Desktop.getDesktop().browse(URI(url)))
     )
     self.add(btn)
def get_rel_path_from_uri(model_context, path_value):
    """
    If the MBean attribute is a URI. To extract it from the archive, need to make
    it into a relative path.
    :param model_context: current context containing run information
    :param path_value: the full value of the path attribute
    :return: The relative value of the path attribute
    """
    uri = URI(path_value)
    if uri.getScheme() == 'file':
        value = model_context.tokenize_path(uri.getPath())
        if value.startswith(model_context.DOMAIN_HOME_TOKEN):
            # point past the token and first slash
            value = value[len(model_context.DOMAIN_HOME_TOKEN) + 1:]
        return value
    return path_value
예제 #17
0
파일: redis.py 프로젝트: nacx/kahuna
def install(version):
    """ Downloads and installs redis """
    script = []
    script.append(Statements.exec("ensure_netutils_apt"))
    script.append(Statements.exec(
        "ensure_cmd_or_install_package_apt make build-essential"))
    script.append(Statements.extractTargzAndFlattenIntoDirectory(
        URI.create("http://redis.googlecode.com/files/redis-%s.tar.gz" %
            version),
        "/usr/local/src/redis"))
    script.append(Statements.exec(
        "(cd /usr/local/src/redis && make && make install)"))
    script.append(Statements.exec("{md} /var/lib/redis"))
    script.append(Statements.exec(
        "sed -i 's/^daemonize no/daemonize yes/' "
        "/usr/local/src/redis/redis.conf"))
    script.append(Statements.exec(
        "sed -i 's/^logfile .*/logfile \/var\/log\/redis.log/' "
        "/usr/local/src/redis/redis.conf"))
    script.append(Statements.exec(
        "sed -i 's/^dbfilename .*/dbfilename redis.rdb/' "
        "/usr/local/src/redis/redis.conf"))
    script.append(Statements.exec(
        "sed -i 's/^dir .*/dir \/var\/lib\/redis/' "
        "/usr/local/src/redis/redis.conf"))
    script.append(Statements.appendFile("/etc/sysctl.conf",
        ["vm.overcommit_memory = 1"]))
    script.append(Statements.exec("sysctl vm.overcommit_memory=1"))
    script.append(Statements.exec(
        "/usr/local/bin/redis-server /usr/local/src/redis/redis.conf"))
    return script
def streamManager(uri):
    """return a StreamManager context for the specified uri"""
    try:
        stream_manager = StreamManager.create(URI(uri))
        yield stream_manager
    finally:
        if stream_manager:
            stream_manager.close()
예제 #19
0
 def open(self, url, new=0, autoraise=1):
     if not Desktop.isDesktopSupported():
         raise Error("webbrowswer.py not supported in your environment")
     try:
         Desktop.getDesktop().browse(URI(url))
         return True
     except IOError as e:
         raise Error(e)
def readerGroupManager(uri, scope):
    """return a ReaderGroupManager context"""
    try:
        reader_group_manager = ReaderGroupManager.withScope(scope, URI(uri))
        yield reader_group_manager
    finally:
        if reader_group_manager:
            reader_group_manager.close()
예제 #21
0
def extract_from_uri(model_context, path_value):
    """
    If the MBean path attribute has a URI file scheme, look past the scheme and
    resolve any global tokens. If the filename contains non-standard RFC 2936 and
    does not represent a file but rather a future file.

    :param model_context: current context containing job information
    :param path_value: MBean attribute path
    :return: fully resolved URI path, or the path_value if not a URI scheme
    """
    _method_name = 'extract_from_uri'
    try:
        uri = URI(path_value)
        if uri.getScheme() == 'file':
            return FILE_URI + model_context.replace_token_string(uri.getPath()[1:])
    except URISyntaxException, use:
        _logger.fine('WLSDPLY-09113', path_value, use, class_name=_class_name, method_name=_method_name)
예제 #22
0
def _get_from_url(cluster_name, file_name):
    """
    Determine if the provided file name is a URL location where the file is hosted. If it is a URL, return
    a URL stream that can be used to retrieve the file from the hosted location.
    :param cluster_name: of the coherence cluster being discovered
    :param file_name: of the file to be tested as a URL
    :return: True if the file is hosted at a URL: URL file handle for the archive file to retrieve the file
    """
    url = None
    try:
        uri = URI(file_name)
        if 'http' == uri.getScheme():
            url = uri.toURL()
    except (URISyntaxException, MalformedURLException), e:
        _logger.warning('WLSDPLY-06321', cluster_name, file_name,
                        e.getLocalizedMessage)
        return False, None
def keyValueTableManager(uri):
    """create a kvt table manager"""
    key_value_table_manager = None
    try:
        key_value_table_manager = KeyValueTableManager.create(URI(uri))
        yield key_value_table_manager
    finally:
        if key_value_table_manager:
            key_value_table_manager.close()
예제 #24
0
 def __init__(self, rally_server, username, password, oauth_key):
     print "Initializing RallyClient\n"
     self.rally_server = rally_server
     rally_url = self.rally_server['url']
     credentials = CredentialsFallback(self.rally_server, username, password).getCredentials()
     self.rest_api = None
     self.configure_proxy()
     self.rest_api = Rally(URI(rally_url), credentials['username'], credentials['password'],
                           apikey=oauth_key if oauth_key else self.rally_server['oAuthKey'], verify_ssl_cert=False)
예제 #25
0
    def onAboutClick(self, event):
        """Open the about webpage of this extension.

        Args:
            event (obj): The Java on click event.

        """

        Desktop.getDesktop().browse(URI("https://github.com/tijme/graphwave"))
예제 #26
0
    def __init__(self, text="Open In Browser"):
        self.menuitem = JMenuItem(text)
        self.menuitem.setEnabled(False)
        self.menuitem.addActionListener(self)

        self.openers = [
            lambda url: Desktop.getDesktop().browse(URI(url)),
            lambda url: subprocess.call(["xdg-open", url]),
            lambda url: subprocess.call(["open", url])
        ]
def eventStreamClientFactory(uri, scope):
    """create an EventStreamClientFactory"""
    clientFactory = None
    try:
        clientFactory = EventStreamClientFactory.withScope(
            scope,
            ClientConfig.builder().controllerURI(URI(uri)).build())
        yield clientFactory
    finally:
        if clientFactory:
            clientFactory.close()
예제 #28
0
    def _button_web_browser_pressed(self, msg):
        url = "http://pages.bao7uo.com"

        field = self._get_btn_field_value(msg)

        if field[0] == "phantomJS_args":
            url = PhantomJS.uri
        elif field[0] == "url":
            url = field[1]

        Desktop.getDesktop().browse(URI(url))
예제 #29
0
def get_rel_path_from_uri(model_context, path_value):
    """
    If the MBean attribute is a URI. To extract it from the archive, need to make
    it into a relative path. If it contains non-standard RF 2396 characters, assume
    it is not a file name in the archive.
    :param model_context: current context containing run information
    :param path_value: the full value of the path attribute
    :return: The relative value of the path attribute
    """
    _method_name = 'get_rel_path_from_uri'
    try:
        uri = URI(path_value)
        if uri.getScheme() == 'file':
            value = model_context.tokenize_path(uri.getPath())
            if value.startswith(model_context.DOMAIN_HOME_TOKEN):
                # point past the token and first slash
                value = value[len(model_context.DOMAIN_HOME_TOKEN)+1:]
            return value
    except URISyntaxException, use:
        _logger.fine('WLSDPLY-09113', path_value, use, class_name=_class_name, method_name=_method_name)
def keyValueTableFactory(uri, scope):
    """create a KeyValueTableFactory"""
    kvt_factory = None
    try:
        kvt_factory = KeyValueTableFactory.withScope(
            scope,
            ClientConfig.builder().controllerURI(URI(uri)).build())
        yield kvt_factory
    finally:
        if kvt_factory:
            kvt_factory.close()
예제 #31
0
    def actionPerformed(self, event):
        import java.awt.Desktop as Desktop
        import java.net.URI as URI

        cmd = event.getActionCommand()

        if cmd == COMMAND_SEND:
            Desktop.getDesktop().browse(
                URI("http://code.google.com/p/mediacomp-jes/issues/list"))

        self.setVisible(0)
        self.dispose()
예제 #32
0
    def __init__(self):

        # self.LaunchApplication("C:\\Program Files (x86)\\HPE\\Unified Functional Testing\\bin\\LFTRuntime.exe")
        newConfig = LFT.ModifiableSDKConfiguration()
        address = URI("ws://localhost:5095")
        print("I am here")
        newConfig.setServerAddress(address)
        print("I am there")
        LFT.SDK.init(newConfig)
        print("I am Done")
        self.appModel = com.company.ApplicationModel()
        print(dir(self.appModel))
예제 #33
0
 def download_file(self, url, filePath):
     """Downloads a file form url and save it as filePath
     """
     try:
         print "\ndownloading"
         print url
         print filePath
         inputStream = URI.create(url).toURL().openStream()
         Files.copy(inputStream, Paths.get(filePath))
         return True
     except (UnknownHostException, SocketException), e:
         print e
         print "I cannot download:\n%s" % url
         return False
예제 #34
0
class XLRequest:

    def __init__(self, url, method, body, username, password, content_type, accept):
        self.__buildCredentials(username, password)
        self.__buildHeaders(content_type, accept)
        self.__buildURI(url)
        self.__buildRequest()
        self.__buildConnection()
        self.method = method
        self.body = body

    def send(self):
        self.connection.request(self.method, self.request, self.body, self.headers)
        return XLResponse.XLResponse(self.connection.getresponse())

    def __buildCredentials(self, username, password):
        if username and password:
            self.credentials = base64.b64encode(username + ':' + password)
        else:
            self.credentials = None

    def __buildHeaders(self, content_type, accept):
        if self.credentials:
            self.headers = {'Authorization': 'Basic ' + self.credentials, 'Content-Type': content_type, 'User-Agent': 'XebiaLabs', 'Accept': accept}
        else:
            self.headers = {'Content-Type': content_type, 'User-Agent': 'XebiaLabs', 'Accept': accept}

    def __buildURI(self, url):
        self.uri = URI(urllib.quote(url, ':/?&=%'))

    def __buildRequest(self):
        self.request = self.uri.getPath()
        if self.uri.getQuery():
            self.request = '%s?%s' % (self.request, self.uri.getQuery())

    

    def __buildConnection(self):
        host = self.uri.getHost()
        if self.uri.getPort() != -1:
            host = '%s:%s' % (host, self.uri.getPort())

        if self.uri.getScheme() == 'https':
            self.connection = httplib.HTTPSConnection(host)
        else:
            self.connection = httplib.HTTPConnection(host)
예제 #35
0
 def __buildURI(self, url):
     self.uri = URI(urllib.quote(url, ':/?&=%'))
예제 #36
0
from java.net import URISyntaxException;
from java.util import List;
from java.util import Iterator;
from java.util import ArrayList;
from java.lang import Object;
from org import jdom
from opendap import dap

from org.apache import log4j;

from ucar.nc2.units import DateType;
from java.lang import StringBuilder

print("This is thredds.__init__()")
#tempURI = java.net.URI
inFileName = "/home/cui/Dropbox/projects/ccesf/code/backesg/esg/esg-octopus/plugouts/thredds/example_v1.xml"
outFileName = "/home/cui/Dropbox/projects/ccesf/code/backesg/esg/esg-octopus/plugouts/thredds/cat_out.xml"
arg = [inFileName, outFileName]
#my_main = CatalogGen.main(arg)
tmpURI = URI( inFileName)
configFile = File( inFileName )
tmpURI = configFile.toURI()
configDocURL = tmpURI.toURL()
log = StringBuilder()
 
catGen = CatalogGen(configDocURL)
if catGen.isValid(log):
  catGen.expand()
  catGen.writeCatalog(outFileName)
     
예제 #37
0
def create(parent):
    demoWidget = JythonScriptDemoWidget(parent, SWT.NONE)
    demoWidget.setScriptPath(URI.create('bundle://au.gov.ansto.bragg.nbi.workbench/scripts/demo/widgets'))
    injectObject(demoWidget)
예제 #38
0
#
# THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS
# FOR A PARTICULAR PURPOSE. THIS CODE AND INFORMATION ARE NOT SUPPORTED BY XEBIALABS.
#

from com.spotify.docker.client import DefaultDockerClient, DockerCertificates
from java.net import URI
from java.nio.file import FileSystems

dockerRunner = deployed.container
serverUrl = dockerRunner.getProperty("serverUrl")
certificateLocation = dockerRunner.getProperty("certificateLocation")

print "Connecting to docker runner: %s" % dockerRunner.name

certificatePath = FileSystems.getDefault().getPath(certificateLocation)
docker = DefaultDockerClient.builder().uri(URI.create(serverUrl)).dockerCertificates(DockerCertificates(certificatePath)).build();
print "Connected to docker runner: %s" % dockerRunner.name

print "Dockerfile located at: %s" % deployed.file.file.getCanonicalPath()

docker.build(deployed.file.file.getParentFile().getCanonicalFile().toPath(),docker.BuildParameter.FORCE_RM)