Ejemplo n.º 1
0
	def render_GET (self, request):
		tpl = template.get("experiment.html")
		
		#print "Render expt"

		defers = []
		variables = {
			"experiment_id": self.expt_id
		}

		def got_title (result):
			#print "Received title"
			variables["experiment_title"] = result

		def got_state (result):
			#print "Received state"
			variables["experiment_state"] = result

		def got_tz (result):
			#print "Received tz"
			variables["experiment_time_zero"] = result

		def got_events (result):
			#print "Received ev"
			variables["experiment_events"] = result

		def got_steps (result):
			#print "Received steps"
			variables["experiment_steps"] = result

		def got_ui (result):
			#print "Received ui"
			variables["experiment_machines"] = result

			# get a single list of all property names
			variables["experiment_properties"] = [
				name 
				for list in [
					[prop["name"] for prop in machine["properties"]]
					for machine in result
				]
				for name in list
			]
			
		try:
			defers.append(self.expt.callRemote("title").addCallback(got_title))
			defers.append(self.expt.callRemote("state").addCallback(got_state))
			defers.append(self.expt.callRemote("time_zero").addCallback(got_tz))
			defers.append(self.expt.callRemote("events").addCallback(got_events))
			defers.append(self.expt.callRemote("steps").addCallback(got_steps))
			defers.append(self.expt.callRemote("ui").addCallback(got_ui))
		except pb.DeadReferenceError:
			return "Experiment not connected"

		def done (result):
			try:
				request.write(tpl.render(**variables).encode('utf-8'))
				request.finish()
			except Exception as e:
				import traceback, pprint
				request.write("Exception during rendering<br><br><pre>%s %s</pre>" % (traceback.format_exc(), pprint.pformat(variables)))
				request.finish()

				raise e

		defer.DeferredList(defers, consumeErrors = True).addCallback(done)

		return server.NOT_DONE_YET
Ejemplo n.º 2
0
    def render_GET(self, request):
        tpl = template.get("experiment.html")

        #print "Render expt"

        defers = []
        variables = {"experiment_id": self.expt_id}

        def got_title(result):
            #print "Received title"
            variables["experiment_title"] = result

        def got_state(result):
            #print "Received state"
            variables["experiment_state"] = result

        def got_tz(result):
            #print "Received tz"
            variables["experiment_time_zero"] = result

        def got_events(result):
            #print "Received ev"
            variables["experiment_events"] = result

        def got_steps(result):
            #print "Received steps"
            variables["experiment_steps"] = result

        def got_ui(result):
            #print "Received ui"
            variables["experiment_machines"] = result

            # get a single list of all property names
            variables["experiment_properties"] = [
                name
                for list in [[prop["name"] for prop in machine["properties"]]
                             for machine in result] for name in list
            ]

        try:
            defers.append(self.expt.callRemote("title").addCallback(got_title))
            defers.append(self.expt.callRemote("state").addCallback(got_state))
            defers.append(
                self.expt.callRemote("time_zero").addCallback(got_tz))
            defers.append(
                self.expt.callRemote("events").addCallback(got_events))
            defers.append(self.expt.callRemote("steps").addCallback(got_steps))
            defers.append(self.expt.callRemote("ui").addCallback(got_ui))
        except pb.DeadReferenceError:
            return "Experiment not connected"

        def done(result):
            try:
                request.write(tpl.render(**variables).encode('utf-8'))
                request.finish()
            except Exception as e:
                import traceback, pprint
                request.write(
                    "Exception during rendering<br><br><pre>%s %s</pre>" %
                    (traceback.format_exc(), pprint.pformat(variables)))
                request.finish()

                raise e

        defer.DeferredList(defers, consumeErrors=True).addCallback(done)

        return server.NOT_DONE_YET
Ejemplo n.º 3
0
def main():
    template_dir = "./template"
    template_dest_dir = "/tmp/lvs/"

    device = "p1p2"

    vipnets = ["10.0.12.0/24"]

    vip2ws = [{
        'wstype':
        'apps',
        'vip':
        '10.0.12.201',
        'wss': ['apps-intngtest0-bgp0.hy01'],
        'ports': [{
            'dport': 80,
            'synproxy': 1,
            'sport': 80,
            'persistence_timeout': 50
        }, {
            'dport': 443,
            'synproxy': 1,
            'sport': 443,
            'persistence_timeout': 50
        }]
    }, {
        'wstype':
        'search',
        'vip':
        '10.0.12.202',
        'wss': ['search-intngtest0-bgp0.hy01'],
        'ports': [{
            'dport': 80,
            'synproxy': 1,
            'sport': 80,
            'persistence_timeout': 50
        }, {
            'dport': 443,
            'synproxy': 1,
            'sport': 443,
            'persistence_timeout': 50
        }]
    }]

    lb_infos = [{
        "internalgateway":
        "10.0.18.1",
        "internalnetmask":
        "255.255.255.224",
        "hostname":
        "sa-intlb0-bgp0.hy01",
        "routerid":
        "10.0.18.2",
        "internalip":
        "10.0.18.2",
        "ospfnet":
        "10.0.18.0/27",
        "localips": [
            '10.0.18.3', '10.0.18.4', '10.0.18.5', '10.0.18.6', '10.0.18.7',
            '10.0.18.8', '10.0.18.9', '10.0.18.10', '10.0.18.11', '10.0.18.12',
            '10.0.18.13', '10.0.18.14', '10.0.18.15', '10.0.18.16',
            '10.0.18.17', '10.0.18.18', '10.0.18.19', '10.0.18.20',
            '10.0.18.21', '10.0.18.22', '10.0.18.23', '10.0.18.24',
            '10.0.18.25', '10.0.18.26', '10.0.18.27', '10.0.18.28',
            '10.0.18.29', '10.0.18.30'
        ]
    }, {
        "internalgateway":
        "10.0.18.33",
        "internalnetmask":
        "255.255.255.224",
        "hostname":
        "sa-intlb1-bgp0.hy01",
        "routerid":
        "10.0.18.34",
        "internalip":
        "10.0.18.34",
        "ospfnet":
        "10.0.18.32/27",
        "localips": [
            '10.0.18.35',
            '10.0.18.36',
            '10.0.18.37',
            '10.0.18.38',
            '10.0.18.39',
            '10.0.18.40',
            '10.0.18.41',
            '10.0.18.42',
            '10.0.18.43',
            '10.0.18.44',
            '10.0.18.45',
            '10.0.18.46',
            '10.0.18.47',
            '10.0.18.48',
            '10.0.18.49',
            '10.0.18.50',
            '10.0.18.51',
            '10.0.18.52',
            '10.0.18.53',
            '10.0.18.54',
            '10.0.18.55',
            '10.0.18.56',
            '10.0.18.57',
            '10.0.18.58',
            '10.0.18.59',
            '10.0.18.60',
            '10.0.18.61',
            '10.0.18.62',
        ]
    }]

    print template.get(template_dir, template_dest_dir, \
        device, vipnets, vip2ws, lb_infos)
Ejemplo n.º 4
0
#!/usr/bin/python3
import mod_path
import template
from headers import *
from polls_db_if import *

print_headers()

navbar = template.get('navbar')
poll_elements = ""

for poll in get_polls():
    poll_title = poll['title']
    poll_choises = ""

    choises = tuple(poll['choises'])

    total_votes = 0
    for choise in choises:
        total_votes += choise['percent']

    for choise in choises:
        choise_title = choise['answer']
        votes_count = choise['percent']
        vote_percent = 0
        if total_votes != 0:
            vote_percent = votes_count / total_votes * 100
        db_id = choise['id']

        poll_choises += template.get('poll_choise').format(**locals())
Ejemplo n.º 5
0
def screen(ticker):
    stock_profiles = []

    print('Fetching profile...')
    stock_profiles.append(
        stockprofile.build_profile(ticker, configuration.DATA_FOLDER))

    # Add description and bid ask prices
    profile = alphaadvanage.add_description_to_profile(
        stock_profiles[0], ticker, configuration.ALPHA_API,
        configuration.DATA_FOLDER)

    print('Fetching analyst feed...')
    price_analysis = stockprofile.get_analyst_feed(ticker,
                                                   configuration.DATA_FOLDER)

    print('Fetching news feed...')
    news = stockprofile.get_news_feed(ticker, configuration.DATA_FOLDER)

    print('Processing news feed...')
    rendered_news = stockprofile.parse_news(news)
    stockprofile.build_bar_charts(
        news, configuration.DATA_FOLDER + 'news-sentiment.png')

    print('Fetching technical analysis...')
    b = brokerage.Brokerage(True, configuration.ALPACA_KEY_ID,
                            configuration.ALPACA_SECRET_KEY,
                            configuration.DATA_FOLDER)
    tech = technical_analysis.analyze(ticker, b)

    print('Fetching Stock Twits...')
    twits = stocktwits.get_messages(ticker, configuration.DATA_FOLDER)

    print('Processing Stock Twits...')
    rendered_twits = stocktwits.process_messages(twits)

    print('Fetching and processing competitors...')
    stock_profiles.extend(
        competitors.build_competitors_list(stock_profiles[0]['industry'],
                                           ticker, configuration.DATA_FOLDER))

    print('Building quarterly finacials chart...')
    alphaadvanage.create_quarterly_financials_chart(
        ticker, configuration.DATA_FOLDER + 'quarterly-reports.png',
        configuration.ALPHA_API, configuration.DATA_FOLDER)

    print('Building report...')

    # Rednder the html template with all the data
    rendered_html = template.get('screener.html').render(
        ticker=ticker,
        stocks=stock_profiles,
        news=rendered_news,
        price_analysis=price_analysis,
        twits=rendered_twits,
        tech=tech)
    rendered_html.encode('utf8')

    # Add the html file to data folder
    with open(configuration.DATA_FOLDER + 'screener.html',
              'w',
              encoding='utf8') as file:
        file.write(rendered_html)

    # Open the html file using the default web browser
    webbrowser.open(configuration.DATA_FOLDER + 'screener.html', new=2)
Ejemplo n.º 6
0
def main():
    template_dir = "./template"
    template_dest_dir = "/tmp/lvs/"

    device = "p1p2"

    vipnets = [
        "10.0.12.0/24"
    ]

    vip2ws = [
        {
            'wstype': 'apps', 
            'vip': '10.0.12.201', 
            'wss': ['apps-intngtest0-bgp0.hy01'], 
            'ports': [
                {'dport': 80, 'synproxy': 1, 'sport': 80, 'persistence_timeout': 50}, 
                {'dport': 443, 'synproxy': 1, 'sport': 443, 'persistence_timeout': 50}
            ]
        },
        {
            'wstype': 'search', 
            'vip': '10.0.12.202', 
            'wss': ['search-intngtest0-bgp0.hy01'], 
            'ports': [
                {'dport': 80, 'synproxy': 1, 'sport': 80, 'persistence_timeout': 50}, 
                {'dport': 443, 'synproxy': 1, 'sport': 443, 'persistence_timeout': 50}
            ]
        }
    ]

    lb_infos = [
        {
            "internalgateway": "10.0.18.1",
            "internalnetmask": "255.255.255.224",
            "hostname": "sa-intlb0-bgp0.hy01",
            "routerid": "10.0.18.2",
            "internalip": "10.0.18.2",
            "ospfnet": "10.0.18.0/27",
            "localips": [
                '10.0.18.3', 
                '10.0.18.4', 
                '10.0.18.5', 
                '10.0.18.6', 
                '10.0.18.7', 
                '10.0.18.8', 
                '10.0.18.9', 
                '10.0.18.10', 
                '10.0.18.11', 
                '10.0.18.12', 
                '10.0.18.13', 
                '10.0.18.14', 
                '10.0.18.15', 
                '10.0.18.16', 
                '10.0.18.17', 
                '10.0.18.18', 
                '10.0.18.19', 
                '10.0.18.20', 
                '10.0.18.21', 
                '10.0.18.22', 
                '10.0.18.23', 
                '10.0.18.24', 
                '10.0.18.25', 
                '10.0.18.26', 
                '10.0.18.27', 
                '10.0.18.28', 
                '10.0.18.29', 
                '10.0.18.30'
            ]
        },
        {
            "internalgateway": "10.0.18.33",
            "internalnetmask": "255.255.255.224",
            "hostname": "sa-intlb1-bgp0.hy01",
            "routerid": "10.0.18.34",
            "internalip": "10.0.18.34",
            "ospfnet": "10.0.18.32/27",
            "localips": [
                '10.0.18.35',
                '10.0.18.36',
                '10.0.18.37',
                '10.0.18.38',
                '10.0.18.39',
                '10.0.18.40',
                '10.0.18.41',
                '10.0.18.42',
                '10.0.18.43',
                '10.0.18.44',
                '10.0.18.45',
                '10.0.18.46',
                '10.0.18.47',
                '10.0.18.48',
                '10.0.18.49',
                '10.0.18.50',
                '10.0.18.51',
                '10.0.18.52',
                '10.0.18.53',
                '10.0.18.54',
                '10.0.18.55',
                '10.0.18.56',
                '10.0.18.57',
                '10.0.18.58',
                '10.0.18.59',
                '10.0.18.60',
                '10.0.18.61',
                '10.0.18.62',
            ]
        }
    ]

    print template.get(template_dir, template_dest_dir, \
        device, vipnets, vip2ws, lb_infos)
Ejemplo n.º 7
0
#!/usr/bin/python3

import mod_path
import template
from headers import *

print_headers()

navbar = template.get("navbar")
print(template.get('about').format(**locals()))
Ejemplo n.º 8
0
#!/usr/bin/python3

import mod_path
import template
from headers import *


print_headers()

navbar = template.get('navbar')
print(template.get('new_poll').format(**locals()))
Ejemplo n.º 9
0
#!/usr/bin/python3
import sys
import os
import mod_path
import template
from headers import *

print_headers()

navbar = template.get("navbar")
print(template.get('contacts').format(**locals()))