Esempio n. 1
0
def module_init():
    """ Called at import """
    args = Options().args
    # Change the current working directory to where all test
    # collections are supposed to reside
    # If script executed with (python test-run.py) dirname is ''
    # so we need to make it .
    path = os.path.dirname(sys.argv[0])
    if not path:
        path = '.'
    os.chdir(path)
    setenv()

    warn_unix_sockets_at_start(args.vardir)

    # always run with clean (non-existent) 'var' directory
    try:
        shutil.rmtree(args.vardir)
    except OSError:
        pass

    args.builddir = os.path.abspath(os.path.expanduser(args.builddir))

    SOURCEDIR = os.path.dirname(os.getcwd())
    BUILDDIR = args.builddir
    os.environ["SOURCEDIR"] = SOURCEDIR
    os.environ["BUILDDIR"] = BUILDDIR
    soext = sys.platform == 'darwin' and 'dylib' or 'so'
    os.environ[
        "LUA_PATH"] = SOURCEDIR + "/?.lua;" + SOURCEDIR + "/?/init.lua;;"
    os.environ["LUA_CPATH"] = BUILDDIR + "/?." + soext + ";;"

    TarantoolServer.find_exe(args.builddir)
    UnittestServer.find_exe(args.builddir)
Esempio n. 2
0
def module_init():
    """ Called at import """
    args = Options().args
    # Change the current working directory to where all test
    # collections are supposed to reside
    # If script executed with (python test-run.py) dirname is ''
    # so we need to make it .
    path = os.path.dirname(sys.argv[0])
    if not path:
        path = '.'
    os.chdir(path)
    setenv()

    warn_unix_sockets_at_start(args.vardir)

    # always run with clean (non-existent) 'var' directory
    try:
        shutil.rmtree(args.vardir)
    except OSError:
        pass

    args.builddir = os.path.abspath(os.path.expanduser(args.builddir))

    SOURCEDIR = os.path.dirname(os.getcwd())
    BUILDDIR = args.builddir
    os.environ["SOURCEDIR"] = SOURCEDIR
    os.environ["BUILDDIR"] = BUILDDIR
    soext = sys.platform == 'darwin' and 'dylib' or 'so'
    os.environ["LUA_PATH"] = SOURCEDIR+"/?.lua;"+SOURCEDIR+"/?/init.lua;;"
    os.environ["LUA_CPATH"] = BUILDDIR+"/?."+soext+";;"

    TarantoolServer.find_exe(args.builddir)
    UnittestServer.find_exe(args.builddir)
Esempio n. 3
0
def run_project(args):
    options = Options()
    options.parse(args)

    if options.known.do_clippings:
        clip = Clippings(options.known.directory)
        clip.parse()
Esempio n. 4
0
def main(workflow):
    query = "" if len(workflow.args) == 0 else workflow.args[0]

    config = workflow.stored_data("configuration")
    if config == None:
        Options.warning(
            "Didn't find your configuration",
            "Please supply your cheat sheet path using 'cf ~/your/path'",
            workflow)
        workflow.send_feedback()
        return -1

    parser = Parser(config.getPath())
    options = Options(parser, workflow)

    tokens = query.strip().split(" ", 1)
    tokens = [i.strip() for i in tokens if i != ""]

    if len(tokens) < 2:
        sheetName = "" if len(tokens) == 0 else tokens[0]
        handler = options.showAvailable if sheetName not in parser.availableSheets(
        ) else options.list
        handler(sheetName)
    else:
        sheetName = tokens[0]
        searchTerm = tokens[1]
        if sheetName == "--search":
            options.search(None, searchTerm)
        else:
            options.search(sheetName, searchTerm)

    workflow.send_feedback()
    return None
Esempio n. 5
0
 def __init__(self, options=None):
     self.options = options or Options()
     self.rsyslog = Rsyslog()
     self.leef = Leef(options)
     self.cef = Cef(options)
     self.sumo = Sumologic()
     self.event_handler = EventHandler()
Esempio n. 6
0
    def __init__(self):
        pygame.init()
        self.options = Options(self)
        self.screen = pygame.display.set_mode(self.options.window_size)
        self.icon = Image("game_icon.png")
        self.caption = "Sunni (Alpha 3.0.0)"
        self.keys = Keys(self)
        self.page = None
        self.file_directory = os.getcwd()[:-3]
        self.mouse = Mouse()
        self.clock = pygame.time.Clock()
        self.fps = 30
        self.start_time = time.time()
        self.current_time = 0   # The amount of time the program as been running
        self.music = Music(self)
        self.saves = [Save(n) for n in range(4)]
        self.selected_save = None
        self.is_running = True
        self.next_battle = None

        self.main_menu = MainMenu(self)
        self.opening_sequence = OpeningSequence(self)
        self.opening_sequence.visit()
        self.new_game_page = NewGamePage(self)
        self.load_game_page = LoadGamePage(self)

        self.player = None
        self.opponent = None

        self.initialise()
        OpeningSequence.initialise()
        NewGamePage.initialise()
        LoadGamePage.initialise()
        Surface.initialise(self)
        Options.initialise()
        Move.initialise(self)
        Character.initialise()
        Player.initialise()
        MainMenu.initialise()
        MemeDog.initialise()
        Battle.initialise()

        self.opponents = OrderedDict()
        self.opponents["Meme Dog"] = MemeDog
        self.opponents["Kanye Snake"] = KanyeSnake
        self.opponents["Spook Dog"] = SpookDog
        self.opponents["Evil Cloud"] = EvilCloud
Esempio n. 7
0
    def __init__(self, ini, test_suite=None):
        self.core = ini['core']
        self.ini = ini
        self.vardir = ini['vardir']
        self.inspector_port = int(
            ini.get('inspector_port', self.DEFAULT_INSPECTOR))
        self.disable_schema_upgrade = Options().args.disable_schema_upgrade
        self.snapshot_path = Options().args.snapshot_path

        # filled in {Test,AppTest,LuaTest,PythonTest}.execute()
        # or passed through execfile() for PythonTest (see
        # TarantoolServer.__init__).
        self.current_test = None

        # Used in valgrind_log property. 'test_suite' is not None only for
        # default servers running in TestSuite.run_all()
        self.test_suite = test_suite
Esempio n. 8
0
 def __init__(self):
     self.scans = ScansController()
     self.servers = ServersController()
     self.queues = QueuesController()
     self.date = DateController()
     self.opts = Options().params()
     self.path = os.path.join(os.path.dirname(__file__), 'details/')
     self.queues.setup_thread(self.files_consumer)
     self.queues.setup_thread(self.scans_consumer)
Esempio n. 9
0
def module_init():
    """ Called at import """
    args = Options().args
    # Change the current working directory to where all test
    # collections are supposed to reside
    # If script executed with (python test-run.py) dirname is ''
    # so we need to make it .
    path = os.path.dirname(sys.argv[0])
    if not path:
        path = '.'
    os.chdir(path)
    setenv()

    # Keep the PWD environment variable in sync with a current
    # working directory. It does not strictly necessary, just to
    # avoid any confusion.
    os.environ['PWD'] = os.getcwd()

    warn_unix_sockets_at_start(args.vardir)

    # always run with clean (non-existent) 'var' directory
    try:
        shutil.rmtree(args.vardir)
    except OSError:
        pass

    args.builddir = os.path.abspath(os.path.expanduser(args.builddir))

    SOURCEDIR = os.path.dirname(os.getcwd())
    BUILDDIR = args.builddir
    os.environ["SOURCEDIR"] = SOURCEDIR
    os.environ["BUILDDIR"] = BUILDDIR
    soext = sys.platform == 'darwin' and 'dylib' or 'so'
    os.environ[
        "LUA_PATH"] = SOURCEDIR + "/?.lua;" + SOURCEDIR + "/?/init.lua;;"
    os.environ["LUA_CPATH"] = BUILDDIR + "/?." + soext + ";;"
    os.environ["REPLICATION_SYNC_TIMEOUT"] = str(args.replication_sync_timeout)
    os.environ['MEMTX_ALLOCATOR'] = args.memtx_allocator

    TarantoolServer.find_exe(args.builddir)
    UnittestServer.find_exe(args.builddir)
    AppServer.find_exe(args.builddir)

    Options().check_schema_upgrade_option(TarantoolServer.debug)
Esempio n. 10
0
def run_server(execs, cwd, server, logfile, retval, test_id):
    os.putenv("LISTEN", server.iproto)
    server.process = Popen(execs, stdout=PIPE, stderr=PIPE, cwd=cwd)
    sampler.register_process(server.process.pid, test_id, server.name)
    test_timeout = Options().args.test_timeout
    timer = Timer(test_timeout, timeout_handler,
                  (server.process, test_timeout))
    timer.start()
    stdout, stderr = server.process.communicate()
    timer.cancel()
    sys.stdout.write_bytes(stdout)
    with open(logfile, 'ab') as f:
        f.write(stderr)
    retval['returncode'] = server.process.wait()
    server.process = None
Esempio n. 11
0
class TestCommandLineParameters(unittest.TestCase):
    def setUp(self):
        self.options = Options()

    def test_defaults_options_are_set(self):
        self.options.parse()
        self.assertEquals(self.options.known.example, 'example-value')

    def test_set_options_example(self):
        self.options.parse(['-x', 'foobar'])
        self.assertEquals(self.options.known.example, 'foobar')
        self.options.parse(['--example', 'not-a-foobar'])
        self.assertEquals(self.options.known.example, 'not-a-foobar')
Esempio n. 12
0
import os
import glob

import sys

from lib.img_preparing import ImgPreparing
from lib.options import Options

if __name__ == '__main__':
    options = Options()
    opts = options.parse(sys.argv[1:])
    img_prepare = ImgPreparing()

    os.system('rm -rf  ' + opts.train_lmdb)
    os.system('rm -rf  ' + opts.validation_lmdb)

    # Get information about images
    train_data = [img for img in glob.glob(opts.train)]
    test_data = [img for img in glob.glob(opts.test)]

    # Create binary views for files
    img_prepare.create_lmdb(train_data, opts.train_lmdb)
    img_prepare.create_lmdb(train_data, opts.validation_lmdb)

Esempio n. 13
0
def test_lib():
	Opt = Options()
	assert_equal(	Opt.parse(['-t', 'source.f']).target,
				 	'source.f')
Esempio n. 14
0
 def __init__(self, options=None):
     self.options = options or Options()
     self.rsyslog = Rsyslog()
     self.leef = Leef(options)
     self.cef = Cef(options)
Esempio n. 15
0
class Game:

    @classmethod
    def initialise(cls):
        cls.OPTIONS_BUTTON = Image("options_button.png", (10, 665))
        cls.VICTORY_OVERLAY = Image("victory_overlay.png", (0, 0))
        cls.DEFEAT_OVERLAY = Image("defeat_overlay.png", (0, 0))
        cls.CONTINUE_BUTTON = Image("continue_button.png", (1000, 600))
        cls.TRY_AGAIN_BUTTON = Image("try_again_button.png", (1000, 600))
        cls.RETURN_TO_TITLE_BUTTON = Image("return_to_title_button.png", (80, 600))

    def __init__(self):
        pygame.init()
        self.options = Options(self)
        self.screen = pygame.display.set_mode(self.options.window_size)
        self.icon = Image("game_icon.png")
        self.caption = "Sunni (Alpha 3.0.0)"
        self.keys = Keys(self)
        self.page = None
        self.file_directory = os.getcwd()[:-3]
        self.mouse = Mouse()
        self.clock = pygame.time.Clock()
        self.fps = 30
        self.start_time = time.time()
        self.current_time = 0   # The amount of time the program as been running
        self.music = Music(self)
        self.saves = [Save(n) for n in range(4)]
        self.selected_save = None
        self.is_running = True
        self.next_battle = None

        self.main_menu = MainMenu(self)
        self.opening_sequence = OpeningSequence(self)
        self.opening_sequence.visit()
        self.new_game_page = NewGamePage(self)
        self.load_game_page = LoadGamePage(self)

        self.player = None
        self.opponent = None

        self.initialise()
        OpeningSequence.initialise()
        NewGamePage.initialise()
        LoadGamePage.initialise()
        Surface.initialise(self)
        Options.initialise()
        Move.initialise(self)
        Character.initialise()
        Player.initialise()
        MainMenu.initialise()
        MemeDog.initialise()
        Battle.initialise()

        self.opponents = OrderedDict()
        self.opponents["Meme Dog"] = MemeDog
        self.opponents["Kanye Snake"] = KanyeSnake
        self.opponents["Spook Dog"] = SpookDog
        self.opponents["Evil Cloud"] = EvilCloud

    @property
    def icon(self):
        return self._icon

    @icon.setter
    def icon(self, icon: Image):
        self._icon = icon
        pygame.display.set_icon(icon.image)

    @property
    def caption(self):
        return self._caption

    @caption.setter
    def caption(self, caption: str):
        self._caption = caption
        pygame.display.set_caption(caption)

    def save(self):
        """Save the current game state to the currently selected save."""
        opponent = self.opponent
        if self.next_battle is not None:
            opponent = self.next_battle.opponent
        self.selected_save.save(self.player.name, self.player.level, opponent.name, self.player.character)

    def select_save(self, save):
        """Sets the save with the given number as the selected save."""
        self.selected_save = save

    def display_save_names(self):
        """Displays all save names (for showing on the saves page)."""
        for save in self.saves:
            save.display_name()

    def load(self):
        """Load the game state represented by self.selected_save."""
        self.player = self.selected_save.create_player(self)
        self.load_next_battle(self.selected_save.opponent_name)
        self.commence_next_battle()

    def load_next_battle(self, name=None):
        if name is None:
            opponent_names = list(self.opponents.keys())
            name = opponent_names[opponent_names.index(self.opponent.name) + 1]

        self.next_battle = Battle(self, self.opponents[name](self))
        if name == "Spook Dog":
            opponent = Character(self, name, 200, 150)
            opponent.ghost_dog_stage = 1     # Variable showing which frame of idle movement the ghost dog is in
            opponent.ghost_dog_glide_x = 930
            opponent.started_glowing = False
            opponent.ghost_dog_attack_time = self.fps/2
            opponent.already_clawed = False

    def commence_next_battle(self):
        """Commence the previously loaded next_battle."""
        self.music.stop_music()
        if isinstance(self.next_battle.opponent, EvilCloud):
            self.main_menu.visit()
            return
        self.page = self.next_battle
        self.opponent = self.next_battle.opponent
        self.next_battle = None

    def run_options_and_return_to_title_logic(self):
        self.RETURN_TO_TITLE_BUTTON.display(1082, 665)
        self.OPTIONS_BUTTON.display(10, 665)
        if self.keys.escape or (self.mouse.is_in(10, 665, 100, 715) and self.mouse.left):
            self.options.show()
        elif self.mouse.is_in(1082, 665, 1270, 715) and self.mouse.left:
            self.main_menu.visit()

    def event_handling(self):
        """Run the code for the main event loop to deal with user inputs/actions."""
        for event in pygame.event.get():    # "For each thing the user does"
            if event.type == pygame.QUIT:
                self.is_running = False
            elif event.type == pygame.TEXTINPUT:
                self.keys.process_text_input(event)
            elif event.type == pygame.MOUSEBUTTONDOWN:
                self.mouse.process_button_down()
            elif event.type == pygame.MOUSEBUTTONUP:
                self.mouse.process_button_up()
            elif event.type == pygame.KEYDOWN:
                self.keys.process_key_down(event)
                self.keys.process_text_input_special_keys()
            elif event.type == pygame.KEYUP:
                self.keys.process_key_up(event)

    def loop(self):
        """Run the main program loop."""
        while self.is_running:
            self.run()

        # Closing the program
        try:
            self.save()
        except (NameError, AttributeError, ValueError):  # in case saving is not yet possible
            pass

        pygame.quit()

    def run(self):
        """Code that is executed once per frame - the body of the main program loop."""
        self.current_time = time.time() - self.start_time
        self.mouse.reset_buttons()
        self.mouse.update_coordinates()
        self.keys.reset()
        self.event_handling()

        if self.options.is_showing and self.page != self.opening_sequence:
            self.options.display()
        else:
            self.page.run()

        pygame.display.flip()       # Updating the screen at the end of drawing
        self.clock.tick(self.fps)   # Setting fps limit
Esempio n. 16
0
        self.changes = self.file_controller.read_file(
            self.changefile)['changes']

    def load_controllers(self):
        self.pl = PlaylistController(self.playlist_df)
        self.user = UserController(self.user_df)
        self.song = SongController(self.song_df)

    def run(self):
        for change in self.changes:
            if change['action'] == 'delete':
                self.playlist_df = self.pl.delete(change['playlist_id'])
            elif change['action'] == 'update':
                if self.song.exist(change['song_id']):
                    self.playlist_df = self.pl.update(change['playlist_id'],
                                                      change['song_id'])
            elif change['action'] == 'create':
                if self.user.exist(change['user_id']):
                    if self.song.exist(change['song_ids']):
                        self.playlist_df = self.pl.create(
                            change['user_id'], change['song_ids'])
            else:
                raise ValueError('Invalid action: %s' % change['action'])
        self.file_controller.write_file(self.output, self.playlist_df)
        return None


if __name__ == "__main__":
    options = Options()
    mt = Mixtape(options)
    mt.run()
Esempio n. 17
0
def main(workflow):
    # Try to read configuration from local disk
    config = workflow.stored_data("configuration")
    if config is None:
        Options.warning("Didn't find your configuration", "Please supply your cheat sheet path using 'cf ~/your/path'", workflow)
        workflow.send_feedback()
        return -1

    parser = Parser(config.getPath())
    # Note: by pasing workflow as a variable, its state is changed in Options.py logic
    options = Options(parser, workflow)

    # Query is whatever comes after "cheat". Stored in one single variable
    query = "" if len(workflow.args) == 0 else workflow.args[0]
    tokens = query.strip().split(" ", 1)  # len 2 list
    tokens = [i.strip() for i in tokens if i != ""]

    if len(tokens) == 0:
        options.showAvailable()
        workflow.send_feedback()
        return None

    if len(tokens) == 1 and tokens[0] == "--search":
        Options.hint("Globally searching for ...?", "In global mode", workflow)
        workflow.send_feedback()
        return None

    if len(tokens) == 1 and tokens[0] not in parser.availableSheets():
        options.showAvailable(tokens[0])
        workflow.send_feedback()
        return None

    if len(tokens) == 1:
        options.list(tokens[0])
        workflow.send_feedback()
        return None

    sheetName = None if tokens[0] == "--search" else tokens[0]
    searchTerm = tokens[1]
    options.searchInSheetByKeyword(sheetName, searchTerm)

    workflow.send_feedback()
    return None
Esempio n. 18
0
 def setUp(self):
     self.options = Options()
Esempio n. 19
0
 def __init__(self, options=None):
     self.options = options or Options()
     self.configs = loadyaml.load_cef()
Esempio n. 20
0
    def execute(self, server):
        super(LuaTest, self).execute(server)

        # Track the same process metrics as part of another test.
        sampler.register_process(server.process.pid, self.id, server.name)

        cls_name = server.__class__.__name__.lower()
        if 'gdb' in cls_name or 'lldb' in cls_name or 'strace' in cls_name:
            # don't propagate gdb/lldb/strace mixin to non-default servers,
            # it doesn't work properly for now
            # TODO: strace isn't interactive, so it's easy to make it works for
            #       non-default server
            create_server = TarantoolServer
        else:
            # propagate valgrind mixin to non-default servers
            create_server = server.__class__
        ts = TestState(
            self.suite_ini, server, create_server,
            self.run_params
        )
        self.inspector.set_parser(ts)
        lua = TestRunGreenlet(self.exec_loop, ts)
        self.current_test_greenlet = lua
        lua.start()
        try:
            save_join(lua, timeout=Options().args.test_timeout)
        except KeyboardInterrupt:
            # prevent tests greenlet from writing to the real stdout
            lua.kill()
            raise
        except TarantoolStartError as e:
            color_stdout('\n[Instance "{0}"] Failed to start tarantool '
                         'instance "{1}"\n'.format(server.name, e.name),
                         schema='error')
            server.kill_current_test()
        finally:
            # Stop any servers created by the test, except the
            # default one.
            #
            # The stop_nondefault() method calls
            # TarantoolServer.stop() under the hood. It sends
            # SIGTERM (if another signal is not passed), waits
            # for 5 seconds for a process termination and, if
            # nothing occurs, sends SIGKILL and continue waiting
            # for the termination.
            #
            # Look, 5 seconds (plus some delay for waiting) for
            # each instance if it does not follow SIGTERM[^1].
            # It is unacceptable, because the difference between
            # --test-timeout (110 seconds by default) and
            # --no-output-timeout (120 seconds by default) may
            # be lower than (5 seconds + delay) * (non-default
            # instance count).
            #
            # That's why we send SIGKILL for residual instances
            # right away.
            #
            # Hitting --no-output-timeout is undesirable, because
            # in the current implementation it is the show-stopper
            # for a testing: test-run doesn't restart fragile
            # tests, doesn't continue processing of other tests,
            # doesn't save artifacts at the end of the testing.
            #
            # [^1]: See gh-4127 and gh-5573 for problems of this
            #       kind.
            ts.stop_nondefault(signal=signal.SIGKILL)
Esempio n. 21
0
from lib.node import Node
from lib.driver import Driver
from lib.options import Options
from lib.log import Log, LogLevel
from lib.vers import ozw_vers_major, ozw_vers_minor, ozw_vers_revision
from lib.xmlfiles import networkFileConfig, DeviceClasses, Manufacturers
from lib.command_classes.commandclasses import CommandClasses
import os
import re
import threading
import psutil
import subprocess
#import copy

MANAGER = None  # A Singleton for manager
OPTIONS = Options()  # A Singleton for Options

#SUPPORTEDCOMMANDCLASSES = {
#    0x71: "COMMAND_CLASS_ALARM",
#    0x22: "COMMAND_CLASS_APPLICATION_STATUS",
#    0x85: "COMMAND_CLASS_ASSOCIATION",
#    0x9b: "COMMAND_CLASS_ASSOCIATION_COMMAND_CONFIGURATION",
#    0x20: "COMMAND_CLASS_BASIC",
#    0x50: "COMMAND_CLASS_BASIC_WINDOW_COVERING",
#    0x80: "COMMAND_CLASS_BATTERY",
#    0x46: "COMMAND_CLASS_CLIMATE_CONTROL_SCHEDULE",
#    0x81: "COMMAND_CLASS_CLOCK",
#    0x70: "COMMAND_CLASS_CONFIGURATION",
#    0x21: "COMMAND_CLASS_CONTROLLER_REPLICATION",
#    0x56: "COMMAND_CLASS_CRC_16_ENCAP" ,
#    0x90: "COMMAND_CLASS_ENERGY_PRODUCTION",
Esempio n. 22
0
 def _default_options(self):
     options = Options()
     options.parse()
     return options