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]))
Example #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
Example #3
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()
Example #4
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)
                )
Example #5
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)
Example #6
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)
Example #7
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])
Example #9
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
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()
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()
Example #12
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 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()
Example #14
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)
Example #15
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"))
Example #16
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])
        ]
Example #17
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))
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()
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()
Example #20
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()
    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))
    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
Example #24
0
    def send_url_to_repeater(url):
        request = cb.helpers.buildHttpRequest(URI(url).toURL())

        parsed_url = urlparse(url)
        port = parsed_url.port
        port = int(port) if port is not None else 80
        cb.callbacks.sendToRepeater(
                        parsed_url.hostname,
                        port,
                        True if parsed_url.scheme == "https" else False,
                        request,
                        "WCF Demo"
                    )
 def __init__(self, subscription_id, tenant_id, client_id, client_key,
              ftp_user, ftp_password, base_url, management_url,
              active_directory_url):
     self.subscription_id = subscription_id
     self.tenant_id = tenant_id
     self.client_id = client_id
     self.client_key = client_key
     self.ftp_user = ftp_user
     self.ftp_password = ftp_password
     self.base_url = URI(base_url)
     self.management_url = management_url
     self.active_directory_url = active_directory_url
     self._access_token = None
     self._zip_media_type = MediaType.parse("application/zip")
     self._json_media_type = MediaType.parse("application/json")
     self._creds = Credentials.basic(self.ftp_user, self.ftp_password)
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
Example #27
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)
Example #28
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
Example #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)
Example #30
0
def submit(request, now=False, block=True,
           broker_uri="tcp://localhost:61616"):
    """Submit an existing ScanRequest to the GDA server.

    See the mscan() docstring for details of `now` and `block`.
    """
    scan_bean = _instantiate(ScanBean, {'scanRequest': request,
                                        'name': '(Jython scan request)'})

    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)