Beispiel #1
0
 def __init__(self, base_url, category='0'):
     self.url = URL(
         base_url,
         self.base_path,
         segments=['category'],
         defaults=[str(category)],
     )
Beispiel #2
0
    def add_trans_proxy(self,location):
        port=self.trans_proxy_mgr.find_proxy(location)
        if port:
            return self._trans_url(URL.get_scheme(location),port)
       
        port=self.port_mgr.alloc_port()
        if not port:
            self.log.error("trans proxy alloc port failed.")
            return None

        self._add_trans_proxy_nginx(location,port)

        self.trans_proxy_mgr.add_proxy(location,port)

        self._reload()

        return self._trans_url(URL.get_scheme(location),port)
Beispiel #3
0
 def __init__(self, base_url, page='0'):
     super(Recent, self).__init__()
     self.url = URL(
         base_url,
         self.base_path,
         segments=['page'],
         defaults=[str(page)],
     )
Beispiel #4
0
 def __init__(self, base_url, query, page='0', order='7', category='0'):
     super(Search, self).__init__()
     self.url = URL(
         base_url,
         self.base_path,
         segments=['query', 'page', 'order', 'category'],
         defaults=[query, str(page),
                   str(order), str(category)],
     )
Beispiel #5
0
    def add_proxy(self,uri_prefix,proxy_uri):
        port,web_url=self.proxy_mgr.find_proxy(uri_prefix)
        if port:
            if proxy_uri==web_url:
                return self._public_url(port,URL.get_path(web_url));
            else:
                self.log.info("uri_prefix %s web_url change from %s to %s"
                              %(uri_prefix,web_url,proxy_uri))
                self.del_proxy(uri_prefix)

        port=self.port_mgr.alloc_port()
        if not port:
            self.log.error("uri_preifx: %s add proxy failed. port not avail."%(uri_prefix))
            return None

        self.proxy_mgr.add_proxy(uri_prefix,proxy_uri,port)

        self._add_proxy_nginx(uri_prefix,proxy_uri,port)

        self._reload()

        return self._public_url(port,URL.get_path(proxy_uri))
Beispiel #6
0
    def _add_proxy_nginx(self,uri_prefix,proxy_uri,port):
        self.log.info("nginx add proxy uri_prefix:%s port:%d"%(uri_prefix,port))

        config_file=self.conf.nginx_config_path+"/conf.d/"+uri_prefix+".conf"

        with open(config_file,"w") as f:
            config=NGINX_WEB_PROXY_FILE_TEMPLATE%(port,
                                                  self._nginx_log_file(uri_prefix),
                                                  self._nginx_log_level(),
                                                  WEB_PROXY_STATIC_PATH,
                                                  self.conf.rest_server_address,
                                                  self.conf.rest_server_port,
                                                  URL.get_base(proxy_uri),
                                                  self.conf.rest_server_address,
                                                  self.conf.rest_server_port
                                                  )
            f.write(config)
            f.close()
Beispiel #7
0
 def query(self, **kwargs):
     group_name = "Token Gateway"
     group = self.topology_builder.create_group(group_name, group_name)
     device_name = self.hostname
     device = group.create_element(device_name, device_name)
     device.add_endpoint(self.hostname, self.port)
     device.add_endpoint(socket.gethostbyname(self.hostname), self.port)
     endpoint_ip = request.get("http://%s:%d/ip" %
                               (self.hostname, self.port))
     if endpoint_ip is not None:
         device.add_endpoint(endpoint_ip,
                             self.port,
                             dnsNames=[self.hostname])
     endpoint_ip = socket.gethostbyname(self.hostname)
     if endpoint_ip is not None:
         device.add_endpoint(endpoint_ip,
                             self.port,
                             dnsNames=[self.hostname])
     response = request.json("http://%s:%d/actuator/env" %
                             (self.hostname, self.port))
     if response is not None:
         for property_source in response["propertySources"]:
             if property_source["name"] == "systemProperties":
                 system_properties = property_source["properties"]
                 device.report_property(
                     "Operating System",
                     system_properties["os.name"]["value"] + " " +
                     system_properties["os.version"]["value"])
                 device.report_property(
                     "Time Zone",
                     system_properties["user.timezone"]["value"])
     measurements = []
     for metric in self.metrics:
         client = MetricClient(URL(self.hostname,
                                   self.port), metric["timeseries"]["key"],
                               metric["source"]["key"])
         for measurement in client.get():
             measurements.append(measurement)
     for measurement in measurements:
         logger.info("key: %s, value: %d" %
                     (measurement.key, measurement.value))
         device.absolute(key=measurement.key,
                         value=measurement.value,
                         dimensions=measurement.dimensions)
Beispiel #8
0
"""

"""
import requests
import logging
import platform
from utils import URL
from io import BytesIO
from zipfile import ZipFile


class UnsupportedPlatformException(Exception):
    pass


CHROME_DRIVER_URL = URL("https://chromedriver.storage.googleapis.com")


def run():
    logging.info("Started install script")
    try:
        logging.info("Searching for latest version of Chrome Driver")
        response = requests.get(CHROME_DRIVER_URL / 'LATEST_RELEASE')
        response.raise_for_status()
        latest_version = response.text
        logging.info(
            f"Latest version of Chrome Driver found: {latest_version}")

        logging.info("Downloading Chrome Driver")
        driver_url = CHROME_DRIVER_URL / latest_version
        if platform.system() == 'Windows':
Beispiel #9
0
 def filehoster(self):
     url = URL(self.base_url, self.torrent_path, self.filehost_path)
     return Filehoster(url, self.customer_id, self.pin)
Beispiel #10
0
 def torrent_cloud(self):
     url = URL(self.base_url, self.torrent_path, self.filehost_path)
     return TorrentCloud(url, self.customer_id, self.pin)