Ejemplo n.º 1
0
    def load_tests(self):
        mh.load_source_file("test_create_product",
                            "../test_cases/test_create_product.py")
        from test_create_product import TestCase_Create_Product as test_case

        self._execute_test(test_case)

        return None
Ejemplo n.º 2
0
 def __init__(self):
     self.config_path = "config/"
     self.module_path = "modules/"
     self.configure()
     self.irc = Irc(self.nick, self.channel)
     # load modules here
     self.module_handler = ModuleHandler(self.module_path, self.irc)
     self.parser = Parser(self.irc, self.module_handler, self.module_path)
     # always load the following:
     self.module_handler.load_module("loader", delay=False, startup=True)
     self.module_handler.load_module("core", delay=False, startup=True)
     self.module_handler.load_module("rand", delay=False, startup=True)
     self.module_handler.load_module("cheese", delay=False, startup=True)
     self.module_handler.load_module("images", delay=False, startup=True)
     self.module_handler.load_module("stackoverflow", delay=False, startup=True)
     self.module_handler.load_module("mood", delay=False, startup=True)
     self.module_handler.load_module("wiki", delay=False, startup=True)
     self.module_handler.load_module("shorty", delay=False, startup=True)
     self.module_handler.load_module("numfact", delay=False, startup=True)
        f.write(header + "\n")
        f.write(D_KEY["needed_module"])
        f.write(D_KEY["documentation"])


if __name__ == "__main__":
    arguments = docopt(__doc__)

    if arguments["list"]:

        if arguments["--installed"]:
            l_repository = [QP_SRC]
        elif arguments["--available-local"]:
            l_repository = [QP_PLUGINS]

        m_instance = ModuleHandler(l_repository)

        for module in sorted(m_instance.l_module):
            print "* {0}".format(module)

    elif arguments["create"]:
        m_instance = ModuleHandler([QP_SRC])

        l_children = arguments["<children_modules>"]

        name = arguments["<name>"][0]

        path = os.path.join(QP_PLUGINS, name)

        print "Created module:"
        print path, "\n"
Ejemplo n.º 4
0
def main(arguments):
    if arguments["list"]:

        if arguments["--installed"]:
            l_repository = [QP_SRC]
        elif arguments["--available-local"]:
            l_repository = [QP_PLUGINS]

        m_instance = ModuleHandler(l_repository)

        for module in sorted(m_instance.l_module):
            print "* {0}".format(module)

    elif arguments["create"]:
        m_instance = ModuleHandler([QP_SRC])

        l_children = arguments["<children_modules>"]

        name = arguments["<name>"][0]

        path = os.path.join(QP_PLUGINS, name)

        print "Created module:"
        print path, '\n'

        for children in l_children:
            if children not in m_instance.dict_descendant:
                print "This module ({0}) is not a valid module.".format(children)
                print "Run `list` for the list of available modules."
                print "Maybe you need to install some other module first."
                print "Aborting..."
                sys.exit(1)

        print "Needed module:"
        print l_children, '\n'

        print "This corresponds to using the following modules:"
        print l_children + m_instance.l_descendant_unique(l_children), '\n'

        print "Which is reduced to:"
        l_child_reduce = m_instance.l_reduce_tree(l_children)
        print l_child_reduce, '\n'

        print "Installation",
        save_new_module(path, l_child_reduce)

        print "    [ OK ]"
#        print "` {0} install {1} `".format(os.path.basename(__file__), name)
        print ""
        arguments["create"]=False
        arguments["install"]=True
        main(arguments)

    elif arguments["download"]:
        print "Not yet implemented"
        pass
#        d_local = get_dict_child([QP_SRC])
#        d_remote = get_dict_child(arguments["<path_folder>"])
#
#        d_child = d_local.copy()
#        d_child.update(d_remote)
#
#        name = arguments["<name>"]
#        l_module_descendant = get_l_module_descendant(d_child, [name])
#
#        for module in l_module_descendant:
#            if module not in d_local:
#                print "you need to install", module

    elif arguments["install"]:

        d_local = get_dict_child([QP_SRC])
        d_plugin = get_dict_child([QP_PLUGINS])

        d_child = d_local.copy()
        d_child.update(d_plugin)

        normalize_case = {}
        for name in d_local.keys() + d_plugin.keys():
            normalize_case [ name.lower() ] = name

        l_name = [ normalize_case[name.lower()] for name in arguments["<name>"] ]

        for name in l_name:
            if name in d_local:
                print "{0} Is already installed".format(name)

        l_module_descendant = get_l_module_descendant(d_child, l_name)

        l_module_to_cp = [module for module in l_module_descendant if module not in d_local]

        if l_module_to_cp:

            print "You will need all these modules"
            print l_module_to_cp

            print "Installation...",

            for module_to_cp in l_module_to_cp:
                    src = os.path.join(QP_PLUGINS, module_to_cp)
                    des = os.path.join(QP_SRC, module_to_cp)
                    try:
                        os.symlink(src, des)
                    except OSError:
                        print "Your src directory is broken. Please remove %s" % des
                        raise
            try:
                subprocess.check_call(["qp_create_ninja.py", "update"])
            except:
                raise

            print "[ OK ]"
            print ""
            print "You can now compile as usual"
            print "`cd {0} ; ninja` for exemple".format(QP_ROOT)
            print " or --in developement mode-- you can cd in a directory and compile here"

    elif arguments["uninstall"]:

        m_instance = ModuleHandler([QP_SRC])
        d_descendant = m_instance.dict_descendant

        d_local = get_dict_child([QP_SRC])
        l_name = arguments["<name>"]

        l_failed = [name for name in l_name if name not in d_local]

        if l_failed:
            print "Modules not installed:"
            for name in sorted(l_failed):
                print "* %s" % name
            sys.exit(1)

        l_name_to_remove = l_name + [module for module in m_instance.l_module for name in l_name if name in d_descendant[module]]

        print "You will remove all of:"
        print l_name_to_remove

        for module in set(l_name_to_remove):

            try:
                subprocess.check_call(["module_handler.py", "clean", module])
            except:
                raise

        for module in set(l_name_to_remove):

            try:
                os.unlink(os.path.join(QP_SRC, module))
            except OSError:
                print "%s is a core module which can't be removed" % module
Ejemplo n.º 5
0
#
# Generated automatically by {0}
#
#
""".format(__file__).replace(QP_ROOT, "$QP_ROOT")

#
# |\ |  _. ._ _   _   _|   _|_     ._  |  _
# | \| (_| | | | (/_ (_|    |_ |_| |_) | (/_
#                                  |
Path = namedtuple('Path', ['abs', 'rel'])
EZ_config_path = namedtuple('EZ_config', ['path_in_module', 'path_in_ezfio'])
EZ_handler = namedtuple('EZ_handler',
                        ['ez_module', 'ez_cfg', 'ez_interface', 'ez_config'])
Sym_link = namedtuple('Sym_link', ['source', 'destination'])
module_instance = ModuleHandler()


def real_join(*args):
    return os.path.realpath(join(*args))


#  _
# |_ ._           _. ._ o  _. |_  |  _   _
# |_ | | \/   \/ (_| |  | (_| |_) | (/_ _>
def ninja_create_env_variable(pwd_config_file):
    """
    Return some ninja variable with the env variable expanded
    FC, FCFLAGS, IRPF90, IRPF90_FLAGS
    The env variable is usefull for the generation of EZFIO, and IRPF90
    """
Ejemplo n.º 6
0
def main(arguments):
    if arguments["list"]:

        if arguments["--installed"]:
            l_repository = [QP_SRC]
        elif arguments["--available-local"]:
            l_repository = [QP_PLUGINS]

        m_instance = ModuleHandler(l_repository)

        for module in sorted(m_instance.l_module):
            print "* {0}".format(module)

    elif arguments["create"]:
        m_instance = ModuleHandler([QP_SRC])

        l_children = arguments["<children_modules>"]

        name = arguments["<name>"][0]

        path = os.path.join(QP_PLUGINS, name)

        print "Created module:"
        print path, '\n'

        for children in l_children:
            if children not in m_instance.dict_descendant:
                print "This module ({0}) is not a valid module.".format(
                    children)
                print "Run `list` for the list of available modules."
                print "Maybe you need to install some other module first."
                print "Aborting..."
                sys.exit(1)

        print "Needed module:"
        print l_children, '\n'

        print "This corresponds to using the following modules:"
        print l_children + m_instance.l_descendant_unique(l_children), '\n'

        print "Which is reduced to:"
        l_child_reduce = m_instance.l_reduce_tree(l_children)
        print l_child_reduce, '\n'

        print "Installation",
        save_new_module(path, l_child_reduce)

        print "    [ OK ]"
        #        print "` {0} install {1} `".format(os.path.basename(__file__), name)
        print ""
        arguments["create"] = False
        arguments["install"] = True
        main(arguments)

    elif arguments["download"]:
        print "Not yet implemented"
        pass


#        d_local = get_dict_child([QP_SRC])
#        d_remote = get_dict_child(arguments["<path_folder>"])
#
#        d_child = d_local.copy()
#        d_child.update(d_remote)
#
#        name = arguments["<name>"]
#        l_module_descendant = get_l_module_descendant(d_child, [name])
#
#        for module in l_module_descendant:
#            if module not in d_local:
#                print "you need to install", module

    elif arguments["install"]:

        d_local = get_dict_child([QP_SRC])
        d_plugin = get_dict_child([QP_PLUGINS])

        d_child = d_local.copy()
        d_child.update(d_plugin)

        normalize_case = {}
        for name in d_local.keys() + d_plugin.keys():
            normalize_case[name.lower()] = name

        l_name = [normalize_case[name.lower()] for name in arguments["<name>"]]

        for name in l_name:
            if name in d_local:
                print "{0} Is already installed".format(name)

        l_module_descendant = get_l_module_descendant(d_child, l_name)

        l_module_to_cp = [
            module for module in l_module_descendant if module not in d_local
        ]

        if l_module_to_cp:

            print "You will need all these modules"
            print l_module_to_cp

            print "Installation...",

            for module_to_cp in l_module_to_cp:
                src = os.path.join(QP_PLUGINS, module_to_cp)
                des = os.path.join(QP_SRC, module_to_cp)
                try:
                    os.symlink(src, des)
                except OSError:
                    print "Your src directory is broken. Please remove %s" % des
                    raise
            try:
                subprocess.check_call(["qp_create_ninja.py", "update"])
            except:
                raise

            print "[ OK ]"
            print ""
            print "You can now compile as usual"
            print "`cd {0} ; ninja` for example".format(QP_ROOT)
            print " or --in developement mode-- you can cd in a directory and compile here"

    elif arguments["uninstall"]:

        m_instance = ModuleHandler([QP_SRC])
        d_descendant = m_instance.dict_descendant

        d_local = get_dict_child([QP_SRC])
        l_name = arguments["<name>"]

        l_failed = [name for name in l_name if name not in d_local]

        if l_failed:
            print "Modules not installed:"
            for name in sorted(l_failed):
                print "* %s" % name
            sys.exit(1)

        l_name_to_remove = l_name + [
            module for module in m_instance.l_module
            for name in l_name if name in d_descendant[module]
        ]

        print "You will remove all of:"
        print l_name_to_remove

        for module in set(l_name_to_remove):

            try:
                subprocess.check_call(["module_handler.py", "clean", module])
            except:
                raise

        for module in set(l_name_to_remove):

            try:
                os.unlink(os.path.join(QP_SRC, module))
            except OSError:
                print "%s is a core module which can't be removed" % module
        f.write(header + "\n")
        f.write(D_KEY["needed_module"])
        f.write(D_KEY["documentation"])


if __name__ == '__main__':
    arguments = docopt(__doc__)

    if arguments["list"]:

        if arguments["--installed"]:
            l_repository = [QP_SRC]
        elif arguments["--available-local"]:
            l_repository = [QP_PLUGINS]

        m_instance = ModuleHandler(l_repository)

        for module in sorted(m_instance.l_module):
            print "* {0}".format(module)

    elif arguments["create"]:
        m_instance = ModuleHandler([QP_SRC])

        l_children = arguments["<children_module>"]

        name = arguments["<name>"][0]

        path = os.path.join(QP_PLUGINS, name)

        print "You will create the module:"
        print path
Ejemplo n.º 8
0
class Gouda:
    def __init__(self):
        self.config_path = "config/"
        self.module_path = "modules/"
        self.configure()
        self.irc = Irc(self.nick, self.channel)
        # load modules here
        self.module_handler = ModuleHandler(self.module_path, self.irc)
        self.parser = Parser(self.irc, self.module_handler, self.module_path)
        # always load the following:
        self.module_handler.load_module("loader", delay=False, startup=True)
        self.module_handler.load_module("core", delay=False, startup=True)
        self.module_handler.load_module("rand", delay=False, startup=True)
        self.module_handler.load_module("cheese", delay=False, startup=True)
        self.module_handler.load_module("images", delay=False, startup=True)
        self.module_handler.load_module("stackoverflow", delay=False, startup=True)
        self.module_handler.load_module("mood", delay=False, startup=True)
        self.module_handler.load_module("wiki", delay=False, startup=True)
        self.module_handler.load_module("shorty", delay=False, startup=True)
        self.module_handler.load_module("numfact", delay=False, startup=True)

    def configure(self):
        config = ConfigLoader(self.config_path + "settings.ini")
        self.nick = config.get_nick()
        self.network = config.get_network()
        self.port = config.get_port()
        self.channel = config.get_channel()

    def run(self):
        self.irc.connect(self.network, self.port)
        while True:
            data = self.irc.receive()
            self.irc.pong(data)
            self.irc.knock_check(data)
            line = self.irc.read(data)
            # send line to parser
            # parser is where modules are loaded etc
            self.parser.run(line)