def infos():
    from platform import platform as platform_version
    from notebook import __version__ as notebook_version
    web_access = True
    try:
        requests.get('https://www.poppy-project.org/')
    except:
        web_access = False
    check_version()

    def service_running(service):
        if os.system('sudo systemctl is-active {}'.format(service)) == 0:
            return True
        else:
            return False

    return render_template(
        'infos.html',
        ip=find_local_ip(),
        platform_version=platform_version().replace('-', ' '),
        python_version=sys.version.replace('\n', ''),
        notebook_version=notebook_version,
        web_access=web_access,
        api_running=pm.running,
        pm_running=service_running(pm.config.services.PuppetMaster),
        jupyter_running=service_running(pm.config.services.JupyterNotebook),
        docs_running=service_running(pm.config.services.PoppyDocs),
        viewer_running=service_running(pm.config.services.PoppyViewer)
    )
예제 #2
0
def index():
    from flask_bootstrap import __version__ as FLASK_BOOTSTRAP_VERSION
    from platform import version as platform_version
    from sys import version as sys_version
    version_info = {
        'flask_bootstrap_version': FLASK_BOOTSTRAP_VERSION,
        'platform_version': platform_version(),
        'sys_version': sys_version.replace('[', '').replace(']', '')
    }
    return render_template('index.html', version_info=version_info)
예제 #3
0
    def __init__(
            self,
            org_id,
            auth_dict=None,
            auth=None,
            ims_host="ims-na1.adobelogin.com",
            ims_endpoint_jwt="/ims/exchange/jwt/",
            user_management_endpoint="https://usermanagement.adobe.io/v2/usermanagement",
            test_mode=False,
            logger=logging.getLogger("umapi_client"),
            retry_max_attempts=4,
            retry_first_delay=15,
            retry_random_delay=5,
            ssl_verify=True,
            timeout_seconds=120.0,
            throttle_actions=10,
            throttle_commands=10,
            throttle_groups=10,
            user_agent=None,
            **kwargs):
        """
        Open a connection for the given parameters that has the given options.
        The connection is authorized and the auth token reused on all calls.

        Required parameters.  You must specify org_id and one of auth *or* auth_dict
        :param org_id: string OrganizationID from Adobe.IO integration data
        :param auth_dict: a dictionary with auth information (see below)
        :param auth: a umapi_client.auth.Auth object containing authorization

        Auth data: if you supply an auth_dict, it must have values for these keys:
        :param tech_acct_id: string technical account ID from Adobe.IO integration data
        :param api_key: string api_key from Adobe.IO integration data
        :param client_secret: string client secret from Adobe.IO integration data
        and one of:
        :param private_key_file: path to local private key file that matches Adobe.IO public key for integration
        or:
        :param private_key_data: the contents of the private_key_file (PEM format)
        (NOTE: for compatibility with User Sync config files, the key names priv_key_path and tech_acct
         are accepted as aliases for private_key_file and tech_acct_id, respectively.)

        Optional connection parameters (defaults are for Adobe production):
        :param ims_host: the IMS host which will exchange your JWT for an access token
        :param ims_endpoint_jwt: the exchange token endpoint on the IMS host
        :param user_management_endpoint: the User Management API service root endpoint

        Behavioral options for the connection:
        :param test_mode: Whether to pass the server-side "test mode" flag when executing actions
        :param logger: The log handler to use (None suppresses logging, default is named "umapi_client")
        :param retry_max_attempts: How many times to retry on temporary errors
        :param retry_first_delay: The time to delay first retry (grows exponentially from there)
        :param retry_random_delay: The max random delay to add on each exponential backoff retry
        :param timeout_seconds: How many seconds to wait for server response (<= 0 or None means forever)
        :param throttle_actions: Max number of actions to pack into a single call
        :param throttle_commands: Max number of commands allowed in a single action
        :param throttle_groups: Max number of groups to add/remove to/from a user
        :param user_agent: (optional) string to use as User-Agent header (umapi-client/version data will be added)

        Additional keywords are allowed to make it easy to pass a big dictionary with other values
        :param kwargs: any keywords passed that we ignore.
        """
        # for testing we mock the server, either by using an http relay
        # which relays and records the requests and responses, or by
        # using a robot which plays back a previously recorded run.
        mock_spec = os.getenv(self.mock_env_var, None)
        if mock_spec:
            if mock_spec not in ["proxy", "playback"]:
                raise ArgumentError("Unknown value for %s: %s" %
                                    (self.mock_env_var, mock_spec))
            if logger:
                logger.warning("%s override specified as '%s'",
                               self.mock_env_var, mock_spec)
            # mocked servers don't support https
            if user_management_endpoint.lower().startswith("https://"):
                user_management_endpoint = "http" + user_management_endpoint[5:]
            # playback servers don't use authentication/authorization
            if mock_spec == "playback":
                auth = Auth("mock", "mock")

        self.org_id = str(org_id)
        self.endpoint = user_management_endpoint
        self.test_mode = test_mode
        self.logger = logger
        self.retry_max_attempts = retry_max_attempts
        self.retry_first_delay = retry_first_delay
        self.retry_random_delay = retry_random_delay
        self.ssl_verify = ssl_verify
        self.timeout = float(timeout_seconds) if timeout_seconds and float(
            timeout_seconds) > 0.0 else None
        self.throttle_actions = max(int(throttle_actions), 1)
        self.throttle_commands = max(int(throttle_commands), 1)
        self.throttle_groups = max(int(throttle_groups), 1)
        self.action_queue = []
        self.local_status = {
            "multiple-query-count": 0,
            "single-query-count": 0,
            "actions-sent": 0,
            "actions-completed": 0,
            "actions-queued": 0
        }
        self.server_status = {
            "status": "Never contacted",
            "endpoint": self.endpoint
        }
        if auth:
            self.auth = auth
        elif auth_dict:
            self.auth = self._get_auth(ims_host=ims_host,
                                       ims_endpoint_jwt=ims_endpoint_jwt,
                                       **auth_dict)
        else:
            raise ArgumentError(
                "Connector create: either auth (an Auth object) or auth_dict (a dict) is required"
            )
        self.session = requests.Session()
        ua_string = "umapi-client/" + umapi_version + " Python/" + python_version(
        ) + " (" + platform_version() + ")"
        if user_agent and user_agent.strip():
            ua_string = user_agent.strip() + " " + ua_string
        self.session.headers["User-Agent"] = ua_string