Beispiel #1
0
 def test_init(self):
     ft = FakeTransmitter(3)
     real_transmission = libhoney.transmission.Transmission
     libhoney.transmission.Transmission = mock.MagicMock(return_value=ft)
     libhoney.init(writekey="wk",
                   dataset="ds",
                   sample_rate=3,
                   api_host="uuu",
                   max_concurrent_batches=5,
                   block_on_response=True)
     self.assertEqual(libhoney.g_writekey, "wk")
     self.assertEqual(libhoney.g_dataset, "ds")
     self.assertEqual(libhoney.g_api_host, "uuu")
     self.assertEqual(libhoney.g_sample_rate, 3)
     self.assertEqual(libhoney._xmit, ft)
     self.assertEqual(libhoney.g_responses, None)
     libhoney.transmission.Transmission.assert_called_with(5, False, True)
     libhoney.transmission.Transmission = real_transmission
Beispiel #2
0
def submit():
    global city, start_date, end_date, preference, weather_date
    global routes, route_distance, weather_output
    city = city_tkvar.get()
    start_date = start_date_entry.get()
    num_days = end_date_entry.get()
    preference = pref_tkver.get()
    if validator(city, start_date, num_days, preference):
        end_date = (dt.datetime.strptime(start_date, "%Y-%m-%d").date() +
                    dt.timedelta(int(num_days))).strftime('%Y-%m-%d')
        weather_date = dt.datetime.strptime(
            start_date, "%Y-%m-%d").date().strftime('%b %-d').upper()
        routes, route_distance, weather_output = init.init(
            city, start_date, end_date, preference)
        table_builder()
Beispiel #3
0
                threadLock.release()
            time.sleep(ticks*5) # 100 seconds


if __name__ == "__main__":
         
    device = formDeviceName()
    init(device)

    # params for wampserver
    ip = sys.argv[1]
    port = sys.argv[2]
    realm = unicode(sys.argv[3])
    path = sys.argv[4]

    __init__.init(path)
    print(ip, port, realm, path)

    global client
    check = client.connect(ip, port, realm)
    
    
    #wait till the connection is established
    time.sleep(5)
    
    #create an instance
    periodicTransmit_I = periodicTransmit(device)
    
    # Launch thread
    handle_heartbeat = periodicTransmit_I.heartbeat()
    handle_containerStatus = periodicTransmit_I.containerStatus()
Beispiel #4
0
# Copyright (C) 2010  David Barnett <*****@*****.**>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

if __name__ == '__main__': from __init__ import init; init()

import unittest
from ranger.gui import ansi

class TestDisplayable(unittest.TestCase):
	def test_char_len(self):
		ansi_string = "X"
		self.assertEqual(ansi.char_len(ansi_string), 1)

	def test_char_len2(self):
		ansi_string = "XY"
		self.assertEqual(ansi.char_len(ansi_string), 2)

	def test_char_len3(self):
		ansi_string = "XY"
Beispiel #5
0
        level = logging.DEBUG, \
        format = '%(asctime)s | %(levelname)s | %(message)s', \
        datefmt = '%Y-%m-%d %H:%M:%S'
    )


# In[4]:


def start():
    logging.info('Start of program'.center(30, '-'))


# In[5]:


def shutdown():
    logging.info('End of program'.center(30, '-'))
    logging.shutdown()


# In[6]:

if __name__ == '__main__':
    __init__.init()
    __config__ = __init__.config.__config__
    init(logpath=__config__.LOG_PATH)
    start()
    logging.debug('Try logging..')
    shutdown()
Beispiel #6
0
import __init__

if __name__ == "__main__":
    __init__.welcome()
    __init__.init()
    __init__.run()
Beispiel #7
0
parser = argparse.ArgumentParser()
parser.add_argument('--task', required=True)
parser.add_argument('--action', choices=["split","check","remove"], required=True)
parser.add_argument('--debug', action='store_true')
parser.add_argument('--monkey_patch', action='store_true')
args = parser.parse_args()

logging.basicConfig(level=(logging.DEBUG if args.debug else logging.INFO), format='%(asctime)-15s: %(message)s [%(filename)s:%(lineno)s]')

task_file = open(args.task+'.json')
task = json.loads(task_file.read())
task_file.close()

sys.path.append("../pymysql_split_tool")
import __init__

if args.monkey_patch:
    import re
    import db
    def new_get_table_structure(database, table):
        '''Change the table creation sql'''
        db.old_get_table_structure(database, table)
        db.db_ori_table_create_sql = re.sub('AUTO_INCREMENT\=\d+', '', db.db_ori_table_create_sql)
        db.db_ori_table_create_sql = db.db_ori_table_create_sql.replace('AUTO_INCREMENT','')
        db.db_ori_table_create_sql = db.db_ori_table_create_sql.replace('PRIMARY KEY (`id`)','PRIMARY KEY (`data_int`)')
        logging.debug(db.db_ori_table_create_sql)
    db.old_get_table_structure = db.get_table_structure
    db.get_table_structure = new_get_table_structure

__init__.init(args.action, task)
__init__.do_work()
Beispiel #8
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import __init__ as _fonts
from collections import OrderedDict
import json
import unicodedata

FS = dict()

_fonts.init(100)

for char in range(0x0, 0xFFFF):
    ucd = unicodedata.name("{}".format(chr(char)), "UNKNOWN")
    if ucd == "UNKNOWN":
        chard = "{} | {} | {}".format(0, ucd, char)
    else:
        chard = "{} | {} | {}".format(chr(char), ucd, hex(char))
    FS[chard] = _fonts.textlength("★" + chr(char) + "★") - 2

FSk = OrderedDict(sorted(FS.items(), key=lambda t: t[0]))
FSs = OrderedDict(sorted(FSk.items(), key=lambda t: t[1]))

print(json.dumps(FSs, ensure_ascii=False, indent="\t", sort_keys=False))
Beispiel #9
0
import argparse
import __init__ as app

app.init()
etl = __import__(app.etl)

# Extraction
raw_data = etl.extract()
# Transform
processed_data = etl.transform(raw_data)
# Load
etl.load(processed_data)
Beispiel #10
0
    print(type(array), array.dtype, array.shape, array[50])
    array = coda.cursor_read_complex_double_split_array(cursor)
    print(type(array), len(array), len(array[0]), type(array[0]),
          array[0].dtype, array[0][50], array[1][50])

    coda.cursor_goto_array_element_by_index(cursor, 50)
    scalar = coda.cursor_read_complex(cursor)
    print(type(scalar), scalar)
    scalar = coda.cursor_read_complex_double_pair(cursor)
    print(type(scalar), scalar.dtype, scalar)
    scalar = coda.cursor_read_complex_double_split(cursor)
    print(type(scalar), scalar)

    coda.close(product)

coda.init()

coda.set_option_bypass_special_types(0)
print(coda.get_option_bypass_special_types())
coda.set_option_perform_boundary_checks(1)
print(coda.get_option_perform_boundary_checks())
coda.set_option_perform_conversions(1)
print(coda.get_option_perform_conversions())
coda.set_option_use_fast_size_expressions(1)
print(coda.get_option_use_fast_size_expressions())
coda.set_option_use_mmap(1)
print(coda.get_option_use_mmap())

for i in range(REPEAT):
    test()
coda.done()
Beispiel #11
0
from __init__ import init
from flask_restful import Api
from routes.Product import add_product, get_all_products, get_product, update_product, delete_product

app = init()
api = Api(app)
api.add_resource(add_product, '/product')
api.add_resource(get_all_products, '/products')
api.add_resource(get_product, '/product/<id>')
api.add_resource(update_product, '/product/<id>')
api.add_resource(delete_product, '/product/<id>')

if __name__ == '__main__':
    app.run(debug=True)
Beispiel #12
0
#!/usr/bin/env python3
# coding=utf8
import __init__ as _fonts
import json
import unicodedata
from collections import OrderedDict

FS = dict()

_fonts.init()

for char in range(0x0, 0xFFFF):
    chard = unicodedata.name("{}".format(chr(char)), "UNKNOWN")
    if chard == "UNKNOWN":
        chard = "{}".format(hex(char))
    FS[chard] = _fonts.textlength(chr(char))

FSk = OrderedDict(sorted(FS.items(), key=lambda t: t[0]))
FSs = OrderedDict(sorted(FSk.items(), key=lambda t: t[1]))

print(json.dumps(FSs, ensure_ascii=False, indent="\t", sort_keys=False))
Beispiel #13
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import __init__ as _fonts
from collections import OrderedDict
import json
import unicodedata

FS = dict()

_fonts.init(100)

for char in range(0x0, 0xFFFF):
    ucd = unicodedata.name("{}".format(chr(char)), "UNKNOWN")
    if ucd == "UNKNOWN":
        chard = "{} | {} | {}".format(0, ucd, char)
    else:
        chard = "{} | {} | {}".format(chr(char), ucd, hex(char))
    FS[chard] = _fonts.textlength("★" + chr(char) + "★")-2

FSk = OrderedDict(sorted(FS.items(), key=lambda t: t[0]))
FSs = OrderedDict(sorted(FSk.items(), key=lambda t: t[1]))

print(json.dumps(FSs, ensure_ascii=False, indent="\t", sort_keys=False))
Beispiel #14
0
            file_holder.close()
            if not isJson:
                player = AudioPlayer(tmp_file_path)
                player.start()
        finally:
            client_sock.close()
            server_sock.close()


class AudioPlayer(threading.Thread):
    def __init__(self,path):
        super().__init__()
        self.path = path

    def run(self):
        tools.playAudio(self.path)

class ConnectionServer(threading.Thread):
    def __init__(self):
        super().__init__()

    def run(self):
        import __init__ as initializer
        initializer.init()
        startBT()

if __name__ == "__main__":
    import __init__ as initializer
    initializer.init()
    startBT()
Beispiel #15
0
import datetime
import logging
import time

from __init__ import init
from component import mymysql, my_async, request_dingding_webhook
from config import app_conf

init()
target_db_pool = mymysql.init(app_conf["mysql"]["target"])
self_db_pool = mymysql.init(app_conf["mysql"]["self"])
logger = logging.getLogger('sync_polardb_slow_log')
logger.setLevel(logging.DEBUG)

local_cache_sql_template_id_2_text = {}
grafana_base_url = app_conf["grafana"]["base_url"]


def post_alarm(msg_content, at_mobiles):
    dingding_webhook_access_token = app_conf["dingding_webhook_access_token"][
        0]
    dingding_resp = request_dingding_webhook.request_dingding_webhook(
        dingding_webhook_access_token, "慢SQL", msg_content, at_mobiles)
    logger.debug(dingding_resp)


def select_sql_template_id_by_text(db_name, sql_template_text):
    # 在本地查询
    global local_cache_sql_template_id_2_text
    if local_cache_sql_template_id_2_text.__contains__(db_name):
        local_cache_sql_template_id_2_text_db_level = local_cache_sql_template_id_2_text[
Beispiel #16
0
 def run(self):
     import __init__ as initializer
     initializer.init()
     startBT()
Beispiel #17
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import

from __init__ import init
init()

from tinyrpc.server import RPCServer
import concurrent.futures


class RPCServerThreaded(RPCServer):
    def __init__(self, *args, **kw):
        self.executor = concurrent.futures.ThreadPoolExecutor(5)

        return RPCServer.__init__(self, *args, **kw)

    def _spawn(self, func, *args, **kwargs):
        self.executor.submit(func, *args, **kwargs)
Beispiel #18
0
        from mapgen import CellularAutomata
        from objects import Floor, Wall
        import ui
        from gridview import HexGridView
        from perception import PGrid
        import globals
        from __init__ import init

        is_debug=True
        logger.setLevel(logging.DEBUG)

        if seeds[0]!=seeds[1]:
            usage()
            exit(1)
        init('asp_spa.conf')
        generator=CellularAutomata(Random(int(seeds[0])),Floor,Wall)
        level=generator.generateLevel(geometry[0],geometry[1])
        tiles=[level[geometry[0]/2,geometry[1]/2]]
        done_tiles=[]
        while tiles[0].blocksLOS():
            tile=tiles.pop(0)
            tiles.extend([t for t in level.getNeighbors(tile.loc) if t not in tiles and t not in done_tiles])
            done_tiles.append(tile)
        tile=tiles[0]
        world=[(i,j,level[i,j].blocksLOS()) for i in xrange(level.width) for j in xrange(level.height)]
        me=(tile.loc[0],tile.loc[1],False)
        perception=PGrid(level, None)
        for t in perception.getTiles():
            t.was_seen=True
        worldview=HexGridView(level, perception)
Beispiel #19
0
def appGenerator():
    init()
    return app