Ejemplo n.º 1
0
    def loopbackTest(self, count=1000, verbose=False):
        i = count
        try:
            while (i > 0):
                # Getting:
                r = server.get("/test/heatingSeetingloopback")
                status = r.status_code
                if (status != 200):
                    self.logger.error(
                        "/test/heatingSeetingloopback did not work, http.status=%s"
                        % (status))
                    return False
                retrievedSettings = r.json()

                if (verbose):
                    self.logger.info(pprint.pformat(retrievedSettings, 2))

                # Putting
                r = server.put("/test/heatingSeetingloopback",
                               json=retrievedSettings)
                status = r.status_code
                if (status != 200):
                    self.logger.error(
                        '/settingsFeedback/0 did not work, http.status=%s' %
                        (status))
                    return False
                i -= 1
            self.logger.info("Passed" + str(count))
            return True
        except ConnectionError:
            self.logger.error(
                "/settingsFeedback/0 did not work (ConnectionError)")
Ejemplo n.º 2
0
 def getSettingsREST(self):
     newSettings = {}
     try:
         r = server.get("/settings/%d" % (self.device))
         status = r.status_code
         if (status != 200):
             self.logger.error("/settings/%d did not work, http.status=%s" %
                               (self.device, status))
         newSettings = r.json()
     except ConnectionError:
         self.logger.debug(
             "/settings/%d did not work (ConnectionError); returning empty settings"
             % (self.device))
     finally:
         self.currentSettings = newSettings
         return self.currentSettings
Ejemplo n.º 3
0
def index():
    if check_login():
        _response = s.get()

        if (_response["Status"]):

            return template(
                'index_template',
                Status=_response["Current_State"],
                Current_Temperature=_response["Current_Temperature"],
                Current_Humidity=_response["Current_Humidity"],
                Target_Temperature=_response["Target_Temperature"],
                Current_Mode=_response["Current_Mode"],
                Stage=_response["Stage"],
                Schedule=_response["Schedule"],
                Web_Root=config.WEBROOT)
        else:
            return ("error_template")
Ejemplo n.º 4
0
#!/usr/bin/env python
{%- from "horizon/map.jinja" import server with context %}

import sys
import os

sys.path.append("/usr/share/openstack-dashboard") 

{# old way #}
{%- for plugin in server.get('plugins', []) %}
sys.path.append('/srv/horizon/plugins/{{ plugin.name }}')
{%- endfor %}

{# new way #}
{%- for plugin_name, plugin in server.get('plugin', {}).iteritems() %}
sys.path.append('/srv/horizon/plugins/{{ plugin_name }}')
{%- endfor %}

from django.core.management import execute_from_command_line

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE",
                          "openstack_dashboard.settings")
    execute_from_command_line(sys.argv)
Ejemplo n.º 5
0
    }
}

{%- if app.broker is defined and app.broker.engine == 'redis' %}
BROKER_URL = 'redis://{{ app.broker.host }}:{{ app.broker.port }}/{{ app.broker.number }}'
CELERY_DEFAULT_QUEUE = "{{ app_name }}"
{%- elif  app.broker is defined and app.broker.engine == 'amqp' %}
BROKER_URL = 'amqp://{{ app.broker.user }}:{{ app.broker.password }}@{{ app.broker.host }}:{{ app.broker.get("port",5672) }}/{{ app.broker.virtual_host }}'
{%- endif %}


SECRET_KEY = '{{ app.get('secret_key', '87941asd897897asd987') }}'

{%- if pillar.nginx is defined %}
{%- from "nginx/map.jinja" import server with context %}
{%- for site_name, site in server.get('site', {}).iteritems() %}
{%- if site.enabled and site.name == app_name and site.ssl is defined and site.ssl is defined and site.ssl.enabled %}
{%- if (app.development is defined and not app.development) or (pillar.linux.system is defined and pillar.linux.system.get('environment', 'prd') != 'dev') %}
# Pass this header from the proxy after terminating the SSL,
# and don't forget to strip it from the client's request.
# For more information see:
# https://docs.djangoproject.com/en/1.8/ref/settings/#secure-proxy-ssl-header
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# If Horizon is being served through SSL, then uncomment the following two
# settings to better secure the cookies from security exploits
CSRF_COOKIE_SECURE = True
SESSION_COOKIE_SECURE = True
# for sure
SECURE_SSL_REDIRECT = True
{%- endif %}
{%- endif %}
#     "regex": '.*',
#     "help_text": _("Your password does not meet the requirements.")
# }

# Turn off browser autocompletion for the login form if so desired.
# HORIZON_CONFIG["password_autocomplete"] = "off"
HORIZON_CONFIG["password_autocomplete"] = "on"

SESSION_TIMEOUT = 86400

# The Horizon Policy Enforcement engine uses these values to load per service
# policy rule files. The content of these files should match the files the
# OpenStack services are using to determine role based access control in the
# target installation.

SESSION_TIMEOUT = {{ server.get('session', {}).get('timeout', 3600) }}
SESSION_ENGINE = "django.contrib.sessions.backends.{{ server.get('session', {}).get('engine', 'signed_cookies') }}"

# Path to directory containing policy.json files
POLICY_FILES_PATH = "{{ server.get('policy_files_path') }}"
# Map of local copy of service policy files
POLICY_FILES = {
    {%- for policy_name, policy in app.get('policy', {}).iteritems() %}
    {%- if policy.get('enabled', True) %}
    "{{ policy_name }}": "{{ policy.get('name') }}",
    {%- endif %}
    {%- endfor %}
}

LOGGING = {
    'version': 1,
Ejemplo n.º 7
0
    sending = False

# The script isn't running, so run it
if sending == False:
    l.debug("Semaphore is False. Running background jobs.")

    # Set a semaphore using PickleDB
    db.set('sending', True)

    # Catch all exceptions here to make sure the semaphore doesn't get stuck
    # at True
    try:
        sql = db.connect()
        # First, send full quality versions of any files that have been
        # requested by photostreamer-server
        response = server.get('/requests/' + str(sender))
        if response:
            for fileId in response:
                saved = upload_full_image(fileId)
                if saved:
                    post_to_server(saved, fileId)
            l.info("Uploaded %d full-resolution file(s) to Amazon S3.",
                len(response))
        elif response == False:
            # API error
            pass
        else:
            l.info("No full-resolution photos have been requested.")

        # Then, send thumbnails that failed to send earlier
        thumbs = sql['thumbs']
{%- from "model_manager/map.jinja" import server with context -%}

SECRET_KEY = '{{ server.secret_key }}'
DEBUG = {{ server.get("debug", False) }}

AVAILABLE_THEMES = [
    ('vendor', 'Default', 'themes/vendor')
]

DEFAULT_THEME = "vendor"

TEMPLATE_LOADERS = (
    'model_manager.utils.themes.ThemeTemplateLoader',
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
    'horizon.loaders.TemplateLoader',
)

{%- if server.integration is defined %}

{%- if server.integration.engine == 'jenkins' %}

JENKINS_API_URL = '{{ server.integration.protocol }}://{{ server.integration.host }}:{{ server.integration.port }}'
JENKINS_API_USERNAME = '******'
JENKINS_API_PASSWORD = '******'

{%- endif %}

{%- if server.integration.model_template is defined %}

COOKIECUTTER_JENKINS_JOB = '{{ server.integration.model_template.job }}'
Ejemplo n.º 9
0
{%- from "taiga/map.jinja" import server with context %}

from .celery import *
from .common import *

DEBUG = {{ server.get('debug', False) }}
TEMPLATE_DEBUG = DEBUG

SECRET_KEY = "{{ server.secret_key }}"

PUBLIC_REGISTER_ENABLED = False

MEDIA_URL = "{{ server.server_protocol }}://{{ server.server_name }}/media/"
STATIC_URL = "{{ server.server_protocol }}://{{ server.server_name }}/static/"
ADMIN_MEDIA_PREFIX = "{{ server.server_protocol }}://{{ server.server_name }}/static/admin/"

SITES["front"]["domain"] = "{{ server.server_name }}"
SITES["front"]["scheme"] = "{{ server.server_protocol }}"

DEFAULT_FROM_EMAIL = "{{ server.mail_from }}"
SERVER_EMAIL = DEFAULT_FROM_EMAIL

EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
{%- if server.mail.get('encryption', 'none') == 'tls' %}
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False
{%- endif %}
{%- if server.mail.get('encryption', 'none') == 'ssl' %}
EMAIL_USE_TLS = False
EMAIL_USE_SSL = True
{%- endif %}
{%- from "robophery/map.jinja" import server with context %}

CONF = {
    'name': '{{ server.name|default(grains.nodename) }}',
    'log_level': '{{ server.log_level|default("info") }}',
    'log_handlers': {{ server.log_handlers|default(["console", "syslog"]) }},
    'read_interval': {{ server.get('read_interval', 10000) }},
    'publish_interval': {{ server.get('publish_interval', 60000) }},
    'platform': '{{ server.platform }}',
    'config': {
        'comm': {{ server.communication }},
        'interface': {{ server.interface }},
        'module': {{ server.module }},
    }
}
Ejemplo n.º 11
0
# header and uncomment the following settings
{%- if server.ssl %}
{%- if server.url is defined %}
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
{%- endif %}
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
{%- endif %}
# If you're not hosting at the root of your web server,
# you need to uncomment and set it to the path where Sentry is hosted.
# FORCE_SCRIPT_NAME = '/sentry'

SENTRY_WEB_HOST = '{{ server.bind.address }}'
SENTRY_WEB_PORT = {{ server.bind.port }}
SENTRY_WEB_OPTIONS = {
    'workers': {{ server.get('workers', '3') }},  # the number of gunicorn workers
#    'secure_scheme_headers': {'X-FORWARDED-PROTO': 'https'},  # detect HTTPS mode from X-Forwarded-Proto header
}

SENTRY_FEATURES = {
    'auth:register': False
}

#SENTRY_ALLOW_ORIGIN = "*"

# You should configure the absolute URI to Sentry. It will attempt to guess it if you don't
# but proxies may interfere with this.
{%- if server.bind.name is defined %}
SENTRY_URL_PREFIX = 'http://{{ server.bind.name }}'
{%- elif pillar.nginx.proxy is defined %}
SENTRY_URL_PREFIX = 'http://{{ server.bind.name }}'
Ejemplo n.º 12
0
{%- from "taiga/map.jinja" import server with context -%}

from .celery import *
from .common import *

DEBUG = {{ server.get('debug', False) }}
TEMPLATE_DEBUG = DEBUG

SECRET_KEY = "{{ server.secret_key }}"

PUBLIC_REGISTER_ENABLED = False

MEDIA_URL = "{{ server.server_protocol }}://{{ server.server_name }}/media/"
STATIC_URL = "{{ server.server_protocol }}://{{ server.server_name }}/static/"
ADMIN_MEDIA_PREFIX = "{{ server.server_protocol }}://{{ server.server_name }}/static/admin/"

SITES["front"]["domain"] = "{{ server.server_name }}"
SITES["front"]["scheme"] = "{{ server.server_protocol }}"

DEFAULT_FROM_EMAIL = "{{ server.get('mail_from', server.mail.from) }}"
SERVER_EMAIL = DEFAULT_FROM_EMAIL

EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
{%- if server.mail.get('encryption', 'none') == 'tls' %}
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False
{%- endif %}
{%- if server.mail.get('encryption', 'none') == 'ssl' %}
EMAIL_USE_TLS = False
EMAIL_USE_SSL = True
{%- endif %}
Ejemplo n.º 13
0
    sending = False

# The script isn't running, so run it
if sending == False:
    l.debug("Semaphore is False. Running background jobs.")

    # Set a semaphore using PickleDB
    db.set('sending', True)

    # Catch all exceptions here to make sure the semaphore doesn't get stuck
    # at True
    try:
        sql = db.connect()
        # First, send full quality versions of any files that have been
        # requested by photostreamer-server
        response = server.get('/requests/' + str(sender))
        if response:
            for fileId in response:
                saved = upload_full_image(fileId)
                if saved:
                    post_to_server(saved, fileId)
            l.info("Uploaded %d full-resolution file(s) to Amazon S3.",
                   len(response))
        elif response == False:
            # API error
            pass
        else:
            l.info("No full-resolution photos have been requested.")

        # Then, send thumbnails that failed to send earlier
        thumbs = sql['thumbs']
Ejemplo n.º 14
0
import server

server = server.Server(log_requests=True)

server.set_port(8080)

def return_page(request):
    res = """
    <html>
        <h1>Wow, this response was parsed correctly and sent as html!</h1>
        <ul>
            <li>list element</li>
        </ul>
    </html>"""
    return res, 200, "text/html"

def load_html(request):
    res = server.read_file("serve.html")
    print(res)
    return res, "text/html"

server.get("/", return_page)
server.get("/hello", load_html)

server.listen()
Ejemplo n.º 15
0
{%- if app.celery.get('result_backend').get('engine') == 'redis' %}
CELERY_RESULT_BACKEND = "redis://{{ app.celery.result_backend.get('host', 'localhost') }}:{{ app.celery.result_backend.get('port', '6379') }}/{{ app.celery.result_backend.get('database', '2') }}"
{%- elif app.celery.get('result_backend').get('engine') == 'amqp' %}
CELERY_RESULT_BACKEND = "amqp://{{ app.celery.result_backend.get('user', 'guest') }}:{{ app.celery.result_backend.get('password', 'guest') }}@{{ app.celery.result_backend.get('host', 'localhost') }}:{{ app.celery.result_backend.get('port', '5672') }}/{{ app.celery.result_backend.get('virtual_host', '/') }}"
{%- elif app.celery.get('result_backend').get('engine') == 'rpc' %}
CELERY_RESULT_BACKEND = "rpc://{{ app.celery.result_backend.get('user', 'guest') }}:{{ app.celery.result_backend.get('password', 'guest') }}@{{ app.celery.result_backend.get('host', 'localhost') }}:{{ app.celery.result_backend.get('port', '5672') }}/{{ app.celery.result_backend.get('virtual_host', '/') }}"
{%- endif %}

{%- endif %}

SECRET_KEY = '{{ app.get('secret_key', '87941asd897897asd987') }}'

{%- if pillar.nginx is defined %}
{%- from "nginx/map.jinja" import server with context %}
{%- for site_name, site in server.get('site', {}).iteritems() %}
{%- if site.enabled and site.name == app_name and site.ssl is defined and site.ssl is defined and site.ssl.enabled %}
{%- if (app.development is defined and not app.development) or (pillar.linux.system is defined and pillar.linux.system.get('environment', 'prd') != 'dev') %}
# Pass this header from the proxy after terminating the SSL,
# and don't forget to strip it from the client's request.
# For more information see:
# https://docs.djangoproject.com/en/1.8/ref/settings/#secure-proxy-ssl-header
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# If Horizon is being served through SSL, then uncomment the following two
# settings to better secure the cookies from security exploits
CSRF_COOKIE_SECURE = True
SESSION_COOKIE_SECURE = True
# for sure
SECURE_SSL_REDIRECT = True
{%- endif %}
{%- endif %}
Ejemplo n.º 16
0
def get(key):
    return server.get(['Plants', key])
Ejemplo n.º 17
0
Archivo: main.py Proyecto: nefa5/WebLeb
import server as ser
print('''

 __          __         _       _               _     
 \ \        / /        | |     | |             | |    
  \ \  /\  / /    ___  | |__   | |        ___  | |__  
   \ \/  \/ /    / _ \ | '_ \  | |       / _ \ | '_ \ 
    \  /\  /    |  __/ | |_) | | |____  |  __/ | |_) |
     \/  \/      \___| |_.__/  |______|  \___| |_.__/ 
                                                      
                                                      


''')
ser.get()
Ejemplo n.º 18
0
{%- from "horizon/map.jinja" import server with context %}

{%- if server.get('secure', True) %}

USE_SSL = True
CSRF_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = True

{%- endif %}
Ejemplo n.º 19
0
CELERY_QUEUES = (
    Queue('default', default_exchange, routing_key='default'),
)

CELERY_DEFAULT_QUEUE = 'default'
CELERY_DEFAULT_EXCHANGE = 'default'
CELERY_DEFAULT_EXCHANGE_TYPE = 'topic'
CELERY_DEFAULT_ROUTING_KEY = 'default'

CELERY_TIMEZONE = 'UTC'

CELERYBEAT_SCHEDULE = {
    'sync_all': {
        'task': 'billometer.tasks.sync_all',
        'schedule': timedelta(seconds={{ server.get("sync_time", 60) }}),
        'args': tuple()
    },
    'collect_all': {
        'task': 'billometer.tasks.collect_all',
        'schedule': timedelta(seconds={{ server.get("collect_time", 120) }}),
        'args': tuple()
    },
    {%- if server.extra_resource is defined and ('network.rx' or 'network.tx') in server.extra_resource.keys() %}
    'sync_network': {
        'task': 'billometer.tasks.network.sync_network',
        'schedule': timedelta(seconds={{ server.get("sync_time", 60) }}),
        'args': tuple()
    },
    'collect_network': {
        'task': 'billometer.tasks.network.collect_network',
# Specify a regular expression to validate user passwords.
# HORIZON_CONFIG["password_validator"] = {
#     "regex": '.*',
#     "help_text": _("Your password does not meet the requirements.")
# }

# Turn off browser autocompletion for the login form if so desired.
# HORIZON_CONFIG["password_autocomplete"] = "off"

# The Horizon Policy Enforcement engine uses these values to load per service
# policy rule files. The content of these files should match the files the
# OpenStack services are using to determine role based access control in the
# target installation.

SESSION_TIMEOUT = {{ server.get('session', {}).get('timeout', 3600) }}
SESSION_ENGINE = "django.contrib.sessions.backends.{{ server.get('session', {}).get('engine', 'signed_cookies') }}"
DROPDOWN_MAX_ITEMS = {{ server.get('dropdown_max_items', 30) }}

# Path to directory containing policy.json files
POLICY_FILES_PATH = "{{ server.get('policy_files_path') }}"
# Map of local copy of service policy files
POLICY_FILES = {
    {%- for policy_name, policy in app.get('policy', {}).iteritems() %}
    {%- if policy.get('enabled', True) %}
    "{{ policy_name }}": "{{ policy.get('name') }}",
    {%- endif %}
    {%- endfor %}
}

LOGGING = {
Ejemplo n.º 21
0
 def test_get(self):
     expected = 'value'
     actual = str(get('key'))
     actual = actual.split('\'')
     actual = actual[1]
     self.assertEqual(expected, actual)