コード例 #1
0
def app():
    cfg = Configuration()
    cfg.parse()

    dummy = Dummy(cfg.fake_count, cfg.snapshots_path)
    dummy.generate()
    dummy.make_snapshot()
コード例 #2
0
def main(parser):

    settings = Settings()
    _config = Configuration()
    config = _config.load_config(path_config=settings.CONFIG_PATH)
    p = parser.parse_args()
    specify_log_path = config['profile']['logging']['specify_log_path']
    path_to_log_dir = config['profile']['logging']['path_to_dir']
    _root_log = LogStream()

    if p.log_dir == 'LOG_DIR' and not specify_log_path:

        log = _root_log.root_logger(silent_logger=p.silent_logger)

    elif p.log_dir == 'LOG_DIR' and specify_log_path:

        log = _root_log.root_logger(silent_logger=p.silent_logger,
                                    _log_dir=path_to_log_dir)

    elif p.log_dir != 'LOG_DIR' and not specify_log_path:

        log = _root_log.root_logger(silent_logger=p.silent_logger,
                                    _log_dir=p.log_dir)

    cliController = CliController(parser)
    cli_options = cliController.cli_options()

    if not len(sys.argv) > 1:

        log.info(
            'Você não acionou nenhum parâmetro. Execute --help para saber opções. Execução padrão iniciada.'
        )

    model = ModelJobxplainer(cli_options)
    model.run()
コード例 #3
0
ファイル: main.py プロジェクト: teploff/otus-highload
def app():
    logger = logging.getLogger()
    logger.setLevel(logging.INFO)

    cfg = Configuration()
    cfg.parse()

    reader = Reader(cfg.snapshots_path)
    reader.do()

    repository = MySQLDriver(cfg.storage)
    repository.insert(
        list(divide_sequence_into_chunks(reader.users, cfg.batch_size)))
コード例 #4
0
    def _init_levelpoints( self, game_data, cheat = False ):
        self.lines = [[(162, 399), (127, 374), (99, 352)], [(58, 354), (49, 287), (55, 235), (64, 210), (89, 196), (123, 196)], [(156, 194), (149, 156), (133, 123), (109, 101), (81, 95), (62, 95)], [(129, 61), (160, 51), (185, 45), (218, 48), (251, 57), (278, 60)], [(319, 67), (334, 96), (348, 121), (348, 142), (342, 159), (326, 167)], [(286, 186), (289, 205), (294, 228), (312, 267)], [(324, 278), (341, 292), (367, 309), (395, 320), (422, 322), (450, 314), (484, 295), (503, 273)], [(472, 260), (497, 244), (529, 232), (552, 204), (556, 171), (532, 158)], [(472, 162), (437, 154), (406, 137), (407, 112), (418, 92), (451, 81), (494, 73), (524, 78), (701, 103), (729, 121), (739, 155), (725, 181), (702, 186), (676, 177), (650, 171), (641, 182), (640, 213), (655, 232)], [(750, 214), (733, 240), (717, 270), (692, 289), (662, 318), (641, 349), (646, 372)], [(732, 393), (696, 421), (657, 453)]]
#        self.lines = [[(98, 443), (165, 372)], [(200, 384), (281, 323), (267, 295)], [(189, 315), (105, 302), (138, 264), (222, 254)], [(257, 270), (306, 216), (262, 184)], [(202, 218), (116, 205), (103, 163), (209, 146), (281, 119)], [(322, 131), (400, 110), (435, 131), (407, 159)], [(386, 155), (379, 189), (448, 219), (457, 241)], [(484, 238), (497, 269), (472, 292), (424, 295)], [(399, 291), (390, 323), (478, 337), (565, 308)], [(575, 305), (582, 270), (601, 259), (559, 245), (565, 227)], [(584, 222), (588, 200), (554, 182)], [(535, 190), (489, 157), (526, 130), (523, 113), (566, 89), (699, 84), (751, 95), (762, 115), (739, 141), (745, 159), (678, 196), (693, 230)], [(710, 238), (694, 277)], [(682, 281), (684, 308), (744, 326), (757, 370), (737, 394)], [(706, 385), (667, 449)]]

        self.lines_length = 0.0

        for seq in self.lines:
            for i in range( 0, len(seq) - 1 ):
                a = Vec2D( seq[i][0], seq[i][1] )
                b = Vec2D( seq[i+1][0], seq[i+1][1] )

                diff = a - b

                self.lines_length += diff.length()


        self.levelpoints = Radiobuttons()

        total_points = game_data.quest.get_level_count()
        config = Configuration.get_instance()
        for i in range( total_points ):
            sprite = resman.get("gui.levelpoint_sprite").clone()
            levelpoint = ImageCheckbox( sprite, self._get_point_place(i, total_points) )
            levelpoint.is_enabled = (i <= config.unlocked_level) or cheat
            self.levelpoints.append( levelpoint )
コード例 #5
0
ファイル: monkey.py プロジェクト: aither64/MysticMine
    def run( self ):
        config = Configuration.get_instance()
        monkey = Monkey( config )

        while not monkey.user_exit:
            print "starting monkey at", datetime.today()
            monkey = Monkey( config )

            try:
                monkey.run( 60 * 5 )
                print "stopped monkey at", datetime.today()
            except Exception, ex:
                info = sys.exc_info()
                traceback.print_exception(info[0], info[1], info[2])
                time.sleep(3)

            print
コード例 #6
0
ファイル: monkey.py プロジェクト: koelnconcert/MysticMine
    def run(self):
        config = Configuration.get_instance()
        monkey = Monkey(config)

        while not monkey.user_exit:
            print "starting monkey at", datetime.today()
            monkey = Monkey(config)

            try:
                monkey.run(60 * 5)
                print "stopped monkey at", datetime.today()
            except Exception, ex:
                info = sys.exc_info()
                traceback.print_exception(info[0], info[1], info[2])
                time.sleep(3)

            print
コード例 #7
0
    def __init__( self, game_data ):
        super(type(self), self).__init__()

        self.game_data = game_data
        self._is_done = False
        self.should_quit = False

        btnFont = Font( "data/edmunds.ttf", color=(0,0,0), size=30, use_antialias = True )

        BUTTON_X = 550
        BUTTON_Y = 180
        H = 65

        self.adventure_btn = ImageButton( copy.copy(resman.get("game.button01_sprite")), Vec2D(BUTTON_X, BUTTON_Y) )
        self.adventure_btn.set_label(_("Adventure"), btnFont )
        self.quick_play  = ImageButton( copy.copy(resman.get("game.button01_sprite")), Vec2D(BUTTON_X, BUTTON_Y + H) )
        self.quick_play.set_label( _("Quick play"), btnFont )
        self.multiplayer_btn  = ImageButton( copy.copy(resman.get("game.button01_sprite")), Vec2D(BUTTON_X, BUTTON_Y + 2*H) )
        self.multiplayer_btn.set_label( _("Multiplayer"), btnFont )
        self.options_btn  = ImageButton( copy.copy(resman.get("game.button01_sprite")), Vec2D(BUTTON_X, BUTTON_Y + 3*H) )
        self.options_btn.set_label( _("Options"), btnFont )
        self.quit_btn  = ImageButton( copy.copy(resman.get("game.button01_sprite")), Vec2D(BUTTON_X, BUTTON_Y + 4*H) )
        self.quit_btn.set_label( _("Quit"), btnFont )

        if Configuration.get_instance().unlocked_level == 0:
            self.quick_play.is_enabled = False
            self.multiplayer_btn.is_enabled = False

        self.add_subcomponent( self.adventure_btn )
        self.add_subcomponent( self.quick_play )
        self.add_subcomponent( self.multiplayer_btn )
        self.add_subcomponent( self.options_btn )
        self.add_subcomponent( self.quit_btn )

        self.update_neighbors()

        self.dialog = None

        self.background = resman.get("gui.logo_surf")

        self.crate_hud = CrateHud( game_data )
        self.car_animation = CarAnimation()
コード例 #8
0
    def __init__( self, game_data ):
        Dialog.__init__( self, Rectangle(140, 80, 800-200, 600-200 ) )
        self.background_image = resman.get("gui.paperdialog_surf")
        self._is_done = False
        self.game_data = game_data

        self.config = Configuration.get_instance()

        btnFont = Font( "data/edmunds.ttf", color=(0,0,0), size=32, use_antialias = True )

        # Game speed, Scroll speed, Single Button mode
        self.speed0_lbl = Label( Vec2D(200, 140), _("Game"), btnFont )
        self.speed1_lbl = Label( Vec2D(200, 170), _("Speed"), btnFont )
        star = ImageButton( copy.copy(resman.get("gui.sheriffstar_sprite") ) )
        self.speed_slider = ImageSlider( Vec2D( 320, 170 ), copy.copy(resman.get("gui.slider_sprite")), star )

        self.oneswitch_btn = ImageButton( copy.copy(resman.get("game.button02_sprite")), Vec2D(300,240) )
        self.update_oneswitch_label()

        self.scan0_lbl = Label( Vec2D(200, 310), _("Scan"), btnFont )
        self.scan1_lbl = Label( Vec2D(200, 340), _("Speed"), btnFont )
        star = ImageButton( copy.copy(resman.get("gui.sheriffstar_sprite") ) )
        self.scan_slider = ImageSlider( Vec2D( 320, 340 ), copy.copy(resman.get("gui.slider_sprite")), star )

        self.close_btn = ImageButton( copy.copy(resman.get("game.button02_sprite")), Vec2D(300,400) )
        self.close_btn.set_label( _("Close"), btnFont )

        self.add_subcomponent( self.speed0_lbl )
        self.add_subcomponent( self.speed1_lbl )
        self.add_subcomponent( self.speed_slider )
        self.add_subcomponent( self.oneswitch_btn )
        self.add_subcomponent( self.scan0_lbl )
        self.add_subcomponent( self.scan1_lbl )
        self.add_subcomponent( self.scan_slider )
        self.add_subcomponent( self.close_btn )

        self.speed_slider.set_value( self.config.game_speed )
        self.scan_slider.set_value( 1.0 - ((self.config.scan_speed - 20) / float(40)) )

        self.update_neighbors()
コード例 #9
0
    def __init__( self, game_data ):
        super(type(self), self).__init__( Rectangle(140, 80, 800-200, 600-200 ) )
        self.background_image = resman.get("gui.paperdialog_surf")
        self._is_done = False
        self.game_data = game_data

        self.dialog = None

        self.config = Configuration.get_instance()

        btnFont = Font( "data/edmunds.ttf", color=(0,0,0), size=32, use_antialias = True )

        self.sound_lbl = Label( Vec2D(200, 130), _("Sound"), btnFont )
        star = ImageButton( copy.copy(resman.get("gui.sheriffstar_sprite") ) )
        self.sound_slider = ImageSlider( Vec2D( 320, 140 ), copy.copy(resman.get("gui.slider_sprite")), star )
        self.music_lbl = Label( Vec2D(200, 195), _("Music"), btnFont )
        star = ImageButton( copy.copy(resman.get("gui.sheriffstar_sprite") ) )
        self.music_slider = ImageSlider( Vec2D( 320, 205 ), copy.copy(resman.get("gui.slider_sprite")), star )
        self.fullscreen_btn = ImageButton( copy.copy(resman.get("game.button02_sprite")), Vec2D(300,260) )
        self.update_fullscreen_label()
        self.access_btn = ImageButton( copy.copy(resman.get("game.button02_sprite")), Vec2D(300,340) )
        self.access_btn.set_label( _("Accessibility"), btnFont )
        self.close_btn = ImageButton( copy.copy(resman.get("game.button02_sprite")), Vec2D(300,420) )
        self.close_btn.set_label( _("Close"), btnFont )

        self.add_subcomponent( self.sound_lbl )
        self.add_subcomponent( self.sound_slider )
        self.add_subcomponent( self.music_lbl )
        self.add_subcomponent( self.music_slider )
        self.add_subcomponent( self.fullscreen_btn )
        self.add_subcomponent( self.access_btn )
        self.add_subcomponent( self.close_btn )

        self.sound_slider.set_value( SoundManager.get_sound_volume() )
        self.music_slider.set_value( SoundManager.get_music_volume() )

        self.update_neighbors()
コード例 #10
0
ファイル: baisikeli.py プロジェクト: OchiengEd/baisikeli
 def __init__(self):
     config = Configuration('baisikeli.conf')
     self.db = Strava_Model()
     self.app_data = json.loads(config.get_strava_app_data())
     self.access_token = None
コード例 #11
0
    def __init__(self):

        settings = Settings()
        _config = Configuration()
        config = _config.load_config(path_config=settings.CONFIG_PATH)
        _authMech = config['profile']['hive']['jdbc']['AuthMech']
        _kRealm = config['profile']['kerberos']['krbRealm']
        _kHostFQDN = config['profile']['kerberos']['krbHostFQDN']
        _kServiceName = config['profile']['kerberos']['krbServiceName']
        _path_dependencies = config['profile']['hive']['jdbc']['dependencies']
        _database = config['profile']['hive']['jdbc']['database']
        _driver = config['profile']['hive']['jdbc']['driver']
        _server = config['profile']['hive']['jdbc']['server']
        _principal = config['profile']['hive']['jdbc']['principal']
        _port = config['profile']['hive']['jdbc']['port']
        path_dependencies = os.path.join(
            settings.CONFIG_PATH,
            'dependencies/hive-jdbc-3.1.2-standalone.jar')

        if _driver == 'org.apache.hive.jdbc.HiveDriver':

            _url = ('jdbc:hive2://{}:{}/{};principal={};'.format(
                _server, str(_port), _database, _principal))

            if _path_dependencies:

                try:

                    _conn = jaydebeapi.connect(jclassname=_driver,
                                               url=_url,
                                               jars=_path_dependencies)

                except Exception as e:

                    raise e

            elif os.path.isfile(path_dependencies):

                try:

                    _conn = jaydebeapi.connect(jclassname=_driver,
                                               url=_url,
                                               jars=path_dependencies)

                except Exception as e:

                    raise e

            else:

                try:

                    _conn = jaydebeapi.connect(jclassname=_driver, url=_url)

                except Exception as e:

                    raise e

        elif _driver == 'com.cloudera.hive.jdbc4.HS2Driver':

            _url = (
                'jdbc:hive2://{}:{}/{};AuthMech={};krbRealm={};krbHostFQDN={};krbServiceName={};'
                .format(_server, str(_port), _database, _authMech, _kRealm,
                        _kHostFQDN, _kServiceName))
            print(_url)

            try:

                _conn = jaydebeapi.connect(jclassname=_driver, url=_url)

            except Exception as e:

                raise e

        self.cursor = _conn.cursor()
コード例 #12
0
ファイル: monkey.py プロジェクト: aither64/MysticMine
            try:
                monkey.run( 60 * 5 )
                print "stopped monkey at", datetime.today()
            except Exception, ex:
                info = sys.exc_info()
                traceback.print_exception(info[0], info[1], info[2])
                time.sleep(3)

            print

if __name__ == '__main__':
    try:
        if "run" in sys.argv[1:]:
            monkeyMaster = MonkeyMaster()
            monkeyMaster.run()
        else:
            replay_file = None
            for f in os.listdir(os.getcwd()):
                if f.startswith("monkeyFailed"):
                    replay_file = f
                    break

            if replay_file is not None:
                monkey = Monkey( Configuration.get_instance(), replay_file )
                monkey.run()
            else:
                print "No failed files!"
    except Exception, ex:
        print "megaexcept!!!!!!"

コード例 #13
0
import json
import os
import colorama
import sys
import webbrowser
import requests
import linecache
import logging
import time
import concurrent.futures as executor
from random import choice
from settings import Configuration

config = Configuration()

logging.basicConfig(filename="VirtualAssistant.log",
                    filemode="a",
                    level=logging.ERROR,
                    format="%(asctime)s | %(levelname)s | %(message)s",
                    datefmt='%m-%d-%Y %I:%M:%S %p')
logger = logging.getLogger(__name__)


def Log(exception_title="", ex_type=logging.ERROR):
    (execution_type, message, tb) = sys.exc_info()

    f = tb.tb_frame
    lineno = tb.tb_lineno
    fname = f.f_code.co_filename.split("\\")[-1]
    linecache.checkcache(fname)
    target = linecache.getline(fname, lineno, f.f_globals)
コード例 #14
0
ファイル: monkey.py プロジェクト: koelnconcert/MysticMine
            try:
                monkey.run(60 * 5)
                print "stopped monkey at", datetime.today()
            except Exception, ex:
                info = sys.exc_info()
                traceback.print_exception(info[0], info[1], info[2])
                time.sleep(3)

            print


if __name__ == '__main__':
    try:
        if "run" in sys.argv[1:]:
            monkeyMaster = MonkeyMaster()
            monkeyMaster.run()
        else:
            replay_file = None
            for f in os.listdir(os.getcwd()):
                if f.startswith("monkeyFailed"):
                    replay_file = f
                    break

            if replay_file is not None:
                monkey = Monkey(Configuration.get_instance(), replay_file)
                monkey.run()
            else:
                print "No failed files!"
    except Exception, ex:
        print "megaexcept!!!!!!"
コード例 #15
0
import logging as log
import tweepy
from settings import Configuration

CONFIG = Configuration()


class TwitterProfile:
    def __init__(self):
        self.twitter_keys = CONFIG.twitter

        # Consumer keys and access tokens, used for OAuth
        self.consumer_key = self.twitter_keys['consumer_key']
        self.consumer_secret = self.twitter_keys['consumer_secret']
        self.access_token = self.twitter_keys['access_token']
        self.access_token_secret = self.twitter_keys['access_secret']

        # OAuth process, using the keys and tokens
        self.auth = tweepy.OAuthHandler(self.consumer_key,
                                        self.consumer_secret)
        self.auth.set_access_token(self.access_token, self.access_token_secret)

        # Creation of the actual interface, using authentication
        self.api = tweepy.API(self.auth)

        # Creates the user object. The me() method returns the user whose
        # authentication keys were used.
        self.user = self.api.me()

    def setBullishProfileStatus(self):
        log.info('Profile set to bullish.')
コード例 #16
0
import os
from settings import Configuration

settings = Configuration()


def toast_notification(title, message, duration=600):
    try:
        import sys
        sys.path.append(settings.UTILS_DIR)
        from send_toast import ToastMessage
        notification = ToastMessage()
        # change the directory to location of batch file to execute
        os.chdir(settings.UTILS_DIR)

        notification.send_toast(title, message, duration=duration)
        # self.tts.respond_to_bot(f"‼️ {title} ‼️")
        # self.tts.respond_to_bot(message)

        # get back to virtual assistant directory
        os.chdir(settings.ASSISTANT_DIR)

    except Exception:
        print("Toast Notification Skill Error.")


try:
    import sys
    sys.path.append(settings.NEWS_DIR)
    from FunHolidays import FunHoliday
    fh = FunHoliday()