Beispiel #1
0
 def decode_recieve_mess(self):
     helper = Help()
     syndrom = helper.mult_matrix_for_vector(self.H_matrix, self.mess)
     leader = self.syndrom_and_leader.get(str(syndrom))
     decode_mess = helper.xor(self.mess, leader)
     print("decode_mess = ", decode_mess[0:self.k])
     print("prob = ", self.prob)
Beispiel #2
0
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        Privileges.check_for_root_permissions()

        self.load_xml_description(self.command_args['--root'])

        package_requests = False
        if self.command_args['--add-package']:
            package_requests = True
        if self.command_args['--delete-package']:
            package_requests = True

        log.info('Updating system')
        self.system = System(self.xml_state,
                             self.command_args['--root'],
                             allow_existing=True)
        manager = self.system.setup_repositories()

        if not package_requests:
            self.system.update_system(manager)
        else:
            if self.command_args['--add-package']:
                self.system.install_packages(
                    manager, self.command_args['--add-package'])
            if self.command_args['--delete-package']:
                self.system.delete_packages(
                    manager, self.command_args['--delete-package'])
Beispiel #3
0
class ResultListTask(CliTask):
    """
        Implements result listing
    """
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        result_directory = os.path.normpath(
            self.command_args['--target-dir']
        )
        log.info(
            'Listing results from %s', result_directory
        )
        result = Result.load(
            result_directory + '/kiwi.result'
        )
        result.print_results()

    def __help(self):
        if self.command_args['help']:
            self.manual.show('kiwi::result::list')
        else:
            return False
        return self.manual
Beispiel #4
0
class SystemCreateTask(CliTask):
    """
        Implements creation of system images
    """
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        Privileges.check_for_root_permissions()

        self.load_xml_description(self.command_args['--root'])

        log.info('Creating system image')
        if not os.path.exists(self.command_args['--target-dir']):
            Path.create(self.command_args['--target-dir'])

        setup = SystemSetup(xml_state=self.xml_state,
                            description_dir=self.command_args['--root'],
                            root_dir=self.command_args['--root'])
        setup.call_image_script()

        image_builder = ImageBuilder(self.xml_state,
                                     self.command_args['--target-dir'],
                                     self.command_args['--root'])
        result = image_builder.create()
        result.print_results()
        result.dump(self.command_args['--target-dir'] + '/kiwi.result')

    def __help(self):
        if self.command_args['help']:
            self.manual.show('kiwi::system::create')
        else:
            return False
        return self.manual
Beispiel #5
0
 def check_for_depend(self):
     helper = Help()
     Comb = Combinatorics()
     for i in range(2, self.d):
         allCombinations = []
         Comb.GenerationAllCombinations(allCombinations, self.n, i)
         for combination in allCombinations:
             new_vector = helper.sum_of_vectors(self.H_transpose, combination)
             #print("new_vector = ", new_vector)
             if (new_vector.count(1) == 0):
                 print("False")
                 print("count = ", new_vector.count(1))
                 print("combination = ", combination)
                 for index in combination:
                     print(self.H_transpose[index])
                 return
     print("True")
     Comb.GenerationAllCombinations(allCombinations, self.n, self.d)
     for combination in allCombinations:
         new_vector = helper.sum_of_vectors(self.H_transpose, combination)
         if (new_vector.count(1) == 0):
             print("depend for d")
             print("combination = ", combination)
             return
     return
Beispiel #6
0
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        Privileges.check_for_root_permissions()

        self.load_xml_description(self.command_args['--description'])

        if self.command_args['--set-repo']:
            (repo_source, repo_type, repo_alias, repo_prio) = \
                self.quadruple_token(self.command_args['--set-repo'])
            self.xml_state.set_repository(repo_source, repo_type, repo_alias,
                                          repo_prio)

        if self.command_args['--add-repo']:
            for add_repo in self.command_args['--add-repo']:
                (repo_source, repo_type, repo_alias, repo_prio) = \
                    self.quadruple_token(add_repo)
                self.xml_state.add_repository(repo_source, repo_type,
                                              repo_alias, repo_prio)

        if os.path.exists('/.buildenv'):
            # This build runs inside of a buildservice worker. Therefore
            # the repo defintions is adapted accordingly
            self.xml_state.translate_obs_to_suse_repositories()

        elif self.command_args['--obs-repo-internal']:
            # This build should use the internal SUSE buildservice
            # Be aware that the buildhost has to provide access
            self.xml_state.translate_obs_to_ibs_repositories()

        log.info('Preparing system')
        system = System(self.xml_state, self.command_args['--root'],
                        self.command_args['--allow-existing-root'])
        manager = system.setup_repositories()
        system.install_bootstrap(manager)
        system.install_system(manager)

        profile = Profile(self.xml_state)

        defaults = Defaults()
        defaults.to_profile(profile)

        setup = SystemSetup(self.xml_state, self.command_args['--description'],
                            self.command_args['--root'])
        setup.import_shell_environment(profile)

        setup.import_description()
        setup.import_overlay_files()
        setup.call_config_script()
        setup.import_image_identifier()
        setup.setup_groups()
        setup.setup_users()
        setup.setup_keyboard_map()
        setup.setup_locale()
        setup.setup_timezone()

        system.pinch_system(manager)
Beispiel #7
0
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        result_directory = os.path.normpath(self.command_args['--target-dir'])
        log.info('Listing results from %s', result_directory)
        result = Result.load(result_directory + '/kiwi.result')
        result.print_results()
Beispiel #8
0
    def do_action(self, conf):
        if self.action == "create-project":
            return Project(conf, self.projectname).create_project()
        elif self.action == "delete-project":
            return Project(conf, self.projectname).delete_project()
        elif self.action == "list":
            conf.list_config()
        elif self.action == "create-sqs":
            return Queue(conf, self.sqsname).create_queue()
        elif self.action == "delete-sqs":
            return Queue(conf, self.sqsname).delete_queue()
        elif self.action == "deploy-project":
            return Project(conf,
                           self.projectname).deploy_project(self.rolename)
        elif self.action == "import-project":
            return Project(conf, self.projectname).import_project()
        elif self.action == "undeploy-project":
            return Project(conf, self.projectname).undeploy_project()
        elif self.action == "deploy-lambda-proxy":
            return Ltklambdaproxy(conf, self.lambdaname).deploy_lambda_proxy(
                self.rolename, self.sqsname)
        elif self.action == "undeploy-lambda-proxy":
            return Ltklambdaproxy(conf,
                                  self.lambdaname).undeploy_lambda_proxy()
        elif self.action == "receiver":
            try:
                Receiver(conf, self.sqsname, self.projectname).receiver()
            except KeyboardInterrupt:
                self.log.info("Stopping the receiver.")
        elif self.action == "tail":
            try:
                Tail(conf, self.lambdaname).tail_log()
            except KeyboardInterrupt:
                self.log.info("Stopping the tail.")
        elif self.action == "set-default-role":
            return Role(conf, self.rolename).set_default_role()
        elif self.action == "unset-default-role":
            return Role(conf, "bypassvalidator").unset_default_role()
        elif self.action == "create-star":
            Utils.define_lambda_role(conf, self.rolename)
            queue_name = Utils.append_fifo_in_queue(self.projectname +
                                                    "_queue")
            conf = Project(conf, self.projectname).create_project()
            conf = Queue(conf, queue_name).create_queue()
            conf = Ltklambdaproxy(conf, self.projectname +
                                  "_proxy").deploy_lambda_proxy(
                                      self.rolename, queue_name)
            return Project(conf,
                           self.projectname).deploy_project(self.rolename)
        elif self.action == "delete-all-configuration":
            conf.delete_all_config()
        else:
            Help.print_help("Invalid command")

        return conf
Beispiel #9
0
 def create_syndrom_table(self):
     helper = Help()
     for coset in self.standart_placement:
         leader = coset[0]
         syndrom = helper.mult_matrix_for_vector(self.H_matrix, leader)
         self.syndrom_table.append(syndrom)
     '''
     print("syndrom_table:")
     for syndrom in self.syndrom_table:
         print(syndrom)
     '''
     return
Beispiel #10
0
 def write_dict_for_decode(self):
     helper = Help()
     print("dictionary_for_decoder:")
     for i in range(0, len(self.standart_placement)):
         syndrom_leader = self.syndrom_table[i]
         print("{", syndrom_leader, ": " , end = '')
         weight_list = list()
         for coset in self.standart_placement[i]:
             weight = helper.calculate_weight_for_vector(coset)
             if (weight <= self.t):
                 weight_list.append(list(coset))
         print(weight_list, "} ")
Beispiel #11
0
 def create_depended_cols(self, size, depend_list):
     helper = Help()
     Comb = Combinatorics()
     for i in range(2, self.d):
         allCombinations = []
         Comb.GenerationAllCombinations(allCombinations, size, i)
         for combination in allCombinations:
             new_vector = helper.sum_of_vectors(self.H_transpose, combination)
             dec = helper.convert_binary_to_decimal(new_vector, self.r)
             #print("dec = ", dec)
             depend_list[dec] = 1
     return
Beispiel #12
0
 def create_code(self):
     random.seed()
     helper = Help()
     code_word = helper.mult_vector_for_matrix(self.mess, self.G_matrix)
     if (self.e == None):
         for i in range(0, self.n):
             value = random.randint(0, 1)
             self.e.append(value)
     print("code_word = ", code_word)
     print("e = ", self.e)
     noise_word = helper.xor(code_word, self.e)
     print("noise_word = ", noise_word)
Beispiel #13
0
 def create_G_matrix(self):
     helper = Help()
     #G_0_transpose = list()
     G_0_transpose = [ list(self.H_matrix[i][0 : self.k]) for i in range(0, self.r) ]
     G_0 = helper.transpose_matrix(G_0_transpose)
     for i in range(0, self.k):
         curr_list = [0 for x in range(0, self.k)]
         curr_list[i] = 1
         self.G_matrix.append(curr_list)
     for i in range(0, self.k):
         for j in range(0, len(G_0[i])):
             self.G_matrix[i].append(G_0[i][j])
     #print("check_G_H_product = ", self.check_G_H_product())
     return
Beispiel #14
0
 def check_G_H_product(self):
     helper = Help()
     matrix = helper.mult_matrix_for_matrix(self.G_matrix, self.H_transpose)
     '''
     print("G_H_product:")
     for row in matrix:
         print(row)
     '''
     sum_ones = 0
     for row in matrix:
         sum_ones = sum_ones + row.count(1)
     if (sum_ones == 0):
         return True
     else:
         return False
Beispiel #15
0
 def build(self):
     self.icon = 'Image/icon.png'
     self.title = 'Mental_math'
     self.theme_cls.primary_palette = "Yellow"
     manager = ScreenManager()
     manager.add_widget(First(name='first'))
     manager.add_widget(Login(name='login'))
     manager.add_widget(Registration(name='registration'))
     manager.add_widget(MainScreen(name='mainscreen'))
     manager.add_widget(Introductory_lesson(name='introductory_lesson'))
     manager.add_widget(Lesson_one(name='lesson_one'))
     manager.add_widget(Lesson_two(name='lesson_two'))
     manager.add_widget(Lesson_three(name='lesson_three'))
     manager.add_widget(Lesson_four(name='lesson_four'))
     manager.add_widget(Lesson_five(name='lesson_five'))
     manager.add_widget(Lesson_six(name='lesson_six'))
     manager.add_widget(Lesson_seven(name='lesson_seven'))
     manager.add_widget(Lesson_eight(name='lesson_eight'))
     manager.add_widget(Lesson_nine(name='lesson_nine'))
     manager.add_widget(Soroban(name='soroban'))
     manager.add_widget(Flashcards(name='flashcards'))
     manager.add_widget(Stolb(name='stolb'))
     manager.add_widget(Help(name='help'))
     manager.add_widget(Audio_tren(name='audio_tren'))
     return manager
Beispiel #16
0
 def __init__(self, chat_id, bot ):
     conn = sqlite3.connect(dataBaseDjangoDir)
     cursor = conn.cursor()
     cursor.execute("""select * from usuarios_usuario""")
     conn.commit()
     query = (cursor.fetchall())
     for user in query:
         if user[4] == chat_id:
             self.name = user[1]
             self.email = user[4]
             self.authorize = True
             self.help = Help(chat_id)
             self.sensiTags = SensiTags(bot)
             self.graphic = Graphics()
             self.report = Reports()
     self.chat_id = chat_id
Beispiel #17
0
 def calculate_dist(self):
     helper = Help()
     sum_combs = 1
     i = 1
     flag = True
     while flag:
         sum_combs = sum_combs + helper.calculate_comb(self.size - 1, i)
         if (sum_combs >= 2 ** self.r):
             flag = False
         else:
             i = i + 1
     dist = i + 1
     if (dist <= self.r - 1):
         return dist
     else:
         return self.r - 1
Beispiel #18
0
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        Privileges.check_for_root_permissions()

        self.load_xml_description(
            self.command_args['--root']
        )

        log.info('Creating system image')
        if not os.path.exists(self.command_args['--target-dir']):
            Path.create(self.command_args['--target-dir'])

        setup = SystemSetup(
            xml_state=self.xml_state,
            description_dir=self.command_args['--root'],
            root_dir=self.command_args['--root']
        )
        setup.call_image_script()

        image_builder = ImageBuilder(
            self.xml_state,
            self.command_args['--target-dir'],
            self.command_args['--root']
        )
        result = image_builder.create()
        result.print_results()
        result.dump(
            self.command_args['--target-dir'] + '/kiwi.result'
        )
Beispiel #19
0
    def __init__(self):
        self.client = zulip.Client(site="https://saharsh.zulipchat.com/api/")
        self.subscribe_all()
        self.trans = Translate()
        self.tw = Twimega()
        self.pnr = Pnr()
        self.weather = Weather()
        self.geo = Geocode()
        self.searching = Places()
        self.help = Help()

        print("Initialization Done ...")
        self.subkeys = [
            "translate", "weather", "pnr", "post", "post_image", "twitter",
            "help", "search"
        ]
Beispiel #20
0
class SystemUpdateTask(CliTask):
    """
        Implements update and maintenance of root systems
    """
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        Privileges.check_for_root_permissions()

        self.load_xml_description(
            self.command_args['--root']
        )

        package_requests = False
        if self.command_args['--add-package']:
            package_requests = True
        if self.command_args['--delete-package']:
            package_requests = True

        log.info('Updating system')
        self.system = System(
            self.xml_state,
            self.command_args['--root'],
            allow_existing=True
        )
        manager = self.system.setup_repositories()

        if not package_requests:
            self.system.update_system(manager)
        else:
            if self.command_args['--add-package']:
                self.system.install_packages(
                    manager, self.command_args['--add-package']
                )
            if self.command_args['--delete-package']:
                self.system.delete_packages(
                    manager, self.command_args['--delete-package']
                )

    def __help(self):
        if self.command_args['help']:
            self.manual.show('kiwi::system::update')
        else:
            return False
        return self.manual
Beispiel #21
0
 def get_args(self, args):
     try:
         opts, args = getopt.getopt(
             args, "p:q:l:r:",
             ["projectname=", "sqsname=", "lambdaname=", "rolename="])
     except getopt.GetoptError:
         Help.print_help("Getopterror")
         exit(1)
     for opt, arg in opts:
         if opt in ("-p", "--projectname"):
             self.projectname = arg
         elif opt in ("-q", "--sqsname"):
             self.sqsname = Utils.append_fifo_in_queue(arg)
         elif opt in ("-r", "--rolename"):
             self.rolename = arg
         elif opt in ("-l", "--lambdaname"):
             self.lambdaname = arg
Beispiel #22
0
    def run():
        print("Welcome to Mardown - README - generator.\nWhat do you want?\nA) Help\tB) Create")
        input1 = input(">> ")

        # Help system
        if input1 == "a" or input1 == "A":
            Help.run()
        # Application system
        elif input1 == "b" or input1 == "B":
            path = Path.run()
            Save.run(path)
            App.init(path)
            App.run()
        # Error
        else:
            print("[!] Choose the options beetwen A or B!")
            Terminal.run()
Beispiel #23
0
    def do_action(self, conf):
        if self.action == "create-project":
            return Project(conf, self.projectname).create_project()
        elif self.action == "delete-project":
            return Project(conf, self.projectname).delete_project()
        elif self.action == "list":
            conf.list_config()
        elif self.action == "create-sqs":
            return Queue(conf, self.sqsname).create_queue()
        elif self.action == "delete-sqs":
            return Queue(conf, self.sqsname).delete_queue()
        elif self.action == "deploy-project":
            return Project(conf,
                           self.projectname).deploy_project(self.rolename)
        elif self.action == "import-project":
            return Project(conf, self.projectname).import_project()
        elif self.action == "undeploy-project":
            return Project(conf, self.projectname).undeploy_project()
        elif self.action == "deploy-lambda-proxy":
            return Ltklambdaproxy(conf, self.lambdaname).deploy_lambda_proxy(
                self.rolename, self.sqsname)
        elif self.action == "undeploy-lambda-proxy":
            return Ltklambdaproxy(conf,
                                  self.lambdaname).undeploy_lambda_proxy()
        elif self.action == "receiver":
            try:
                Receiver(conf, self.sqsname, self.projectname).receiver()
            except KeyboardInterrupt:
                print("Stopping the receive.")
        elif self.action == "set-default-role":
            Role(conf, self.rolename).set_default_role()
        elif self.action == "create-star":
            conf = Project(conf, self.projectname).create_project()
            conf = Queue(conf, self.projectname + "_queue").create_queue()
            conf = Ltklambdaproxy(
                conf, self.projectname + "_proxy").deploy_lambda_proxy(
                    self.rolename, self.projectname + "_queue")
            return Project(conf,
                           self.projectname).deploy_project(self.rolename)
        elif self.action == "delete-all-configuration":
            conf.delete_all_config()
        else:
            Help.print_help("Invalid command")

        return conf
Beispiel #24
0
 def create_standart_placement(self):
     helper = Help()
     code_words = list()
     for word in self.words:
         code_word = helper.mult_vector_for_matrix(word, self.G_matrix)
         code_words.append(code_word)
     '''
     print("code_words:")
     for code_word in code_words:
         print(code_word)
     '''
     self.standart_placement.append(code_words)
     depend_list = [0 for x in range(0, 2 ** self.n)]
     for code_word in code_words:
         dec = helper.convert_binary_to_decimal(code_word, self.n)
         depend_list[dec] = 1
     for i in range(0, 2 ** self.r - 1):
         leader = helper.find_min_weight_in_depend_list(depend_list, self.n)
         #print("leader = ", leader)
         coset = list()
         for code_word in code_words:
             coset_word = helper.xor(leader, code_word)
             dec = helper.convert_binary_to_decimal(coset_word, self.n)
             depend_list[dec] = 1
             #print("coset_word = ", coset_word)
             coset.append(coset_word)
         self.standart_placement.append(coset)
     #print("depend_list = ", depend_list)
     return
Beispiel #25
0
 def check_for_liniar_code(self):
     helper = Help()
     i = 0
     code_words = self.standart_placement[0]
     while i < len(code_words):
         j = i + 1
         while j < len(code_words):
             sum_vector = helper.xor(code_words[i], code_words[j])
             if (not(sum_vector in code_words)):
                 print("code is not liniar")
                 print("i = ", i)
                 print("j = ", j)
                 print(code_words[i])
                 print(code_words[j])
             j = j + 1
         i = i + 1
     print("code is liniar")
     return
Beispiel #26
0
    def __init__(self, cmd=None):
        self.db = initdb()

        self.header_string = "Xapers"
        self.status_string = "s: search, q: kill buffer, Q: quit Xapers, ?: help and additional commands"

        self.view = urwid.Frame(urwid.SolidFill())
        self.set_header()
        self.set_status()
        self.devnull = open('/dev/null', 'rw')

        if not cmd:
            cmd = ['search', '*']

        if cmd[0] == 'search':
            query = ' '.join(cmd[1:])
            self.buffer = Search(self, query)
        elif cmd[0] == 'bibview':
            query = ' '.join(cmd[1:])
            self.buffer = Bibview(self, query)
        elif cmd[0] == 'help':
            target = None
            if len(cmd) > 1:
                target = cmd[1]
            if isinstance(target, str):
                target = None
            self.buffer = Help(self, target)
        else:
            self.buffer = Help(self)
            self.set_status("Unknown command '%s'." % (cmd[0]))

        self.merge_palette(self.buffer)

        self.view.body = urwid.AttrMap(self.buffer, 'body')

        self.mainloop = urwid.MainLoop(
            self.view,
            self.palette,
            unhandled_input=self.keypress,
            handle_mouse=False,
        )
        self.mainloop.screen.set_terminal_properties(colors=88)
        self.mainloop.run()
Beispiel #27
0
 def calculate_dist(self):
     helper = Help()
     sum_combs = 1
     i = 1
     flag = True
     #print("2**r = ", 2 ** self.r)
     while flag:
         #print("i = ", i, ": ", helper.calculate_comb(self.n - 1, i))
         sum_combs = sum_combs + helper.calculate_comb(self.n - 1, i)
         #print("sum_combs = ", sum_combs)
         if (sum_combs >= 2 ** self.r):
             flag = False
         else:
             i = i + 1
     dist = i + 1
     if (dist <= self.r - 1):
         return dist
     else:
         return self.r - 1
Beispiel #28
0
 def calculate_probability(self):
     helper = Help()
     syn_leader_list = list()
     weight_and_count = dict()
     for i in range(0, self.t + 1):
         weight_and_count[i] = 0
     i = 0
     while i < len(self.standart_placement):
         leader = self.standart_placement[i][0]
         weight = helper.calculate_weight_for_vector(leader)
         if (weight <= self.t):
             weight_and_count[weight] = weight_and_count[weight] + 1
         i = i + 1
     prob_e_leader = 0
     for weight in weight_and_count.keys():
         prob = (self.p ** weight) * ((1 - self.p) ** (self.n - weight))
         prob_e_leader = prob_e_leader + (weight_and_count[weight] * prob)
     prob_e_not_leader = 1 - prob_e_leader
     return prob_e_not_leader
Beispiel #29
0
class SystemCreateTask(CliTask):
    """
        Implements creation of system images
    """
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        Privileges.check_for_root_permissions()

        self.load_xml_description(
            self.command_args['--root']
        )

        log.info('Creating system image')
        if not os.path.exists(self.command_args['--target-dir']):
            Path.create(self.command_args['--target-dir'])

        setup = SystemSetup(
            xml_state=self.xml_state,
            description_dir=self.command_args['--root'],
            root_dir=self.command_args['--root']
        )
        setup.call_image_script()

        image_builder = ImageBuilder(
            self.xml_state,
            self.command_args['--target-dir'],
            self.command_args['--root']
        )
        result = image_builder.create()
        result.print_results()
        result.dump(
            self.command_args['--target-dir'] + '/kiwi.result'
        )

    def __help(self):
        if self.command_args['help']:
            self.manual.show('kiwi::system::create')
        else:
            return False
        return self.manual
Beispiel #30
0
 def get_args(self, args):
     try:
         opts, args = getopt.getopt(
             args, "p:q:l:r:",
             ["projectname=", "sqsname=", "lambdaname=", "rolename="])
     except getopt.GetoptError:
         Help.print_help("Getopterror")
         exit(1)
     for opt, arg in opts:
         if opt in ("-p", "--projectname"):
             self.projectname = arg
         elif opt in ("-q", "--sqsname"):
             if arg.endswith(".fifo"):
                 self.sqsname = arg
             else:
                 self.sqsname = arg + ".fifo"
         elif opt in ("-r", "--rolename"):
             self.rolename = arg
         elif opt in ("-l", "--lambdaname"):
             self.lambdaname = arg
Beispiel #31
0
class ResultListTask(CliTask):
    """
        Implements result listing
    """
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        result_directory = os.path.normpath(self.command_args['--target-dir'])
        log.info('Listing results from %s', result_directory)
        result = Result.load(result_directory + '/kiwi.result')
        result.print_results()

    def __help(self):
        if self.command_args['help']:
            self.manual.show('kiwi::result::list')
        else:
            return False
        return self.manual
Beispiel #32
0
class SystemUpdateTask(CliTask):
    """
        Implements update and maintenance of root systems
    """
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        Privileges.check_for_root_permissions()

        self.load_xml_description(self.command_args['--root'])

        package_requests = False
        if self.command_args['--add-package']:
            package_requests = True
        if self.command_args['--delete-package']:
            package_requests = True

        log.info('Updating system')
        self.system = System(self.xml_state,
                             self.command_args['--root'],
                             allow_existing=True)
        manager = self.system.setup_repositories()

        if not package_requests:
            self.system.update_system(manager)
        else:
            if self.command_args['--add-package']:
                self.system.install_packages(
                    manager, self.command_args['--add-package'])
            if self.command_args['--delete-package']:
                self.system.delete_packages(
                    manager, self.command_args['--delete-package'])

    def __help(self):
        if self.command_args['help']:
            self.manual.show('kiwi::system::update')
        else:
            return False
        return self.manual
Beispiel #33
0
def identify_task(task_word):
    task = ''
    if 'song' == task_word:
        task = Find_song()
    if 'answer' == task_word:
        task = Find_answer()
    if 'spell' == task_word:
        task = Spell_word()
    if 'time' == task_word or 'date' == task_word:
        task = Say_date_time()
    if 'help' == task_word:
        task = Help()
    return task
Beispiel #34
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.initStyleSheet()

        self.tcp_server = TcpServer(self)
        self.tcp_clients = TcpClients(self)
        self.udp_server = UdpServer(self)
        self.help = Help(self)

        self.init_ui()
        self.init_connect()
        self.init_config()
Beispiel #35
0
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        result_directory = os.path.normpath(
            self.command_args['--target-dir']
        )
        log.info(
            'Listing results from %s', result_directory
        )
        result = Result.load(
            result_directory + '/kiwi.result'
        )
        result.print_results()
Beispiel #36
0
class Coffesploit(object):
    """Main Class"""
    def __init__(self, basepath):
        self.target = Target()
        self.tool = None
        self.pluginmanager = PluginManager()
        self.helper = Help()
        self.basepath = basepath
        
    def set_target(self,rhost=None,url=None):
        if url is not None:
            self.target.seturl(url)
        if rhost is not None:
            self.target.setrhost(rhost)
    def set(self, arg1, arg2):
        self.pluginmanager.current_plugin.set_arg(arg1,arg2)
    def show(self,arg):
        if arg == "target":
            print "ip:",self.target.getrhost(),"url:",self.target.geturl()
        if arg == "status":
            if self.pluginmanager.current_plugin is not None:
                self.pluginmanager.plugin_status()
        if arg == "version":
            print "Currnt Version:",self.version()
                
    def use(self,arg):
        self.pluginmanager.load_plugin(arg)
        
    def run(self):
        self.pluginmanager.plugin_run()
        self.pluginmanager.plugin_result()

    def main_help (self):
        return self.helper.main_help()
    def main_list (self):
        return self.pluginmanager.importer.get_plugins_list()
    def help(self,arg):
        """show help info of t"""
        if arg == "target":
            self.helper.help_set_tartget()
        if arg == "show":
            self.helper.help_show()
        if arg == "use":
            self.helper.help_use()
    def exit(self):
        exit(0)
    def version(self):
        return __Version__
Beispiel #37
0
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        Privileges.check_for_root_permissions()

        self.load_xml_description(
            self.command_args['--root']
        )

        package_requests = False
        if self.command_args['--add-package']:
            package_requests = True
        if self.command_args['--delete-package']:
            package_requests = True

        log.info('Updating system')
        self.system = System(
            self.xml_state,
            self.command_args['--root'],
            allow_existing=True
        )
        manager = self.system.setup_repositories()

        if not package_requests:
            self.system.update_system(manager)
        else:
            if self.command_args['--add-package']:
                self.system.install_packages(
                    manager, self.command_args['--add-package']
                )
            if self.command_args['--delete-package']:
                self.system.delete_packages(
                    manager, self.command_args['--delete-package']
                )
Beispiel #38
0
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        Privileges.check_for_root_permissions()

        image_root = self.command_args['--target-dir'] + '/build/image-root'
        Path.create(image_root)

        if not self.global_args['--logfile']:
            log.set_logfile(
                self.command_args['--target-dir'] + '/build/image-root.log'
            )

        self.load_xml_description(
            self.command_args['--description']
        )

        if self.command_args['--set-repo']:
            (repo_source, repo_type, repo_alias, repo_prio) = \
                self.quadruple_token(self.command_args['--set-repo'])
            self.xml_state.set_repository(
                repo_source, repo_type, repo_alias, repo_prio
            )

        if self.command_args['--add-repo']:
            for add_repo in self.command_args['--add-repo']:
                (repo_source, repo_type, repo_alias, repo_prio) = \
                    self.quadruple_token(add_repo)
                self.xml_state.add_repository(
                    repo_source, repo_type, repo_alias, repo_prio
                )

                Path.create(self.command_args['--target-dir'])

        if os.path.exists('/.buildenv'):
            # This build runs inside of a buildservice worker. Therefore
            # the repo defintions is adapted accordingly
            self.xml_state.translate_obs_to_suse_repositories()

        elif self.command_args['--obs-repo-internal']:
            # This build should use the internal SUSE buildservice
            # Be aware that the buildhost has to provide access
            self.xml_state.translate_obs_to_ibs_repositories()

        log.info('Preparing new root system')
        system = System(
            self.xml_state, image_root, True
        )
        manager = system.setup_repositories()
        system.install_bootstrap(manager)
        system.install_system(
            manager
        )

        profile = Profile(self.xml_state)

        defaults = Defaults()
        defaults.to_profile(profile)

        setup = SystemSetup(
            self.xml_state,
            self.command_args['--description'],
            image_root
        )
        setup.import_shell_environment(profile)

        setup.import_description()
        setup.import_overlay_files()
        setup.call_config_script()
        setup.import_image_identifier()
        setup.setup_groups()
        setup.setup_users()
        setup.setup_keyboard_map()
        setup.setup_locale()
        setup.setup_timezone()

        system.pinch_system(
            manager
        )
        # make sure system instance is cleaned up now
        del system

        setup.call_image_script()

        # make sure setup instance is cleaned up now
        del setup

        log.info('Creating system image')
        image_builder = ImageBuilder(
            self.xml_state,
            self.command_args['--target-dir'],
            image_root
        )
        result = image_builder.create()
        result.print_results()
        result.dump(
            self.command_args['--target-dir'] + '/kiwi.result'
        )
Beispiel #39
0
        return 'verbose'
    if '-s' == arg or '--save' == arg:
        return 'save'

print_help = False
verbose_output = False
save_output = False
help_arg = None

for arg in sys.argv:
    index = sys.argv.index(arg)
    option = __parse_arg(arg)
    if option is 'help':
        print_help = True
        try:
            help_arg = __parse_arg(sys.argv[index+1])
        except Exception:
            help_arg = None

    if option is 'verbose':
        verbose_output = True
    if option is 'save':
        save_output = True

if print_help == True:
    Help.print_help(help_arg)
else:
    # Execute the Console program
    console = Console()
    console.console()
    
Beispiel #40
0
 def show_and_exit_on_help_request(self):
     if self.all_args['help']:
         manual = Help()
         manual.show('kiwi')
         sys.exit(0)
Beispiel #41
0
 def helpAction(self):
     a = Help()
     a.__init__()
Beispiel #42
0
 def __init__(self, basepath):
     self.target = Target()
     self.tool = None
     self.pluginmanager = PluginManager()
     self.helper = Help()
     self.basepath = basepath
Beispiel #43
0
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        Privileges.check_for_root_permissions()

        self.load_xml_description(
            self.command_args['--description']
        )

        if self.command_args['--set-repo']:
            (repo_source, repo_type, repo_alias, repo_prio) = \
                self.quadruple_token(self.command_args['--set-repo'])
            self.xml_state.set_repository(
                repo_source, repo_type, repo_alias, repo_prio
            )

        if self.command_args['--add-repo']:
            for add_repo in self.command_args['--add-repo']:
                (repo_source, repo_type, repo_alias, repo_prio) = \
                    self.quadruple_token(add_repo)
                self.xml_state.add_repository(
                    repo_source, repo_type, repo_alias, repo_prio
                )

        if os.path.exists('/.buildenv'):
            # This build runs inside of a buildservice worker. Therefore
            # the repo defintions is adapted accordingly
            self.xml_state.translate_obs_to_suse_repositories()

        elif self.command_args['--obs-repo-internal']:
            # This build should use the internal SUSE buildservice
            # Be aware that the buildhost has to provide access
            self.xml_state.translate_obs_to_ibs_repositories()

        log.info('Preparing system')
        system = System(
            self.xml_state,
            self.command_args['--root'],
            self.command_args['--allow-existing-root']
        )
        manager = system.setup_repositories()
        system.install_bootstrap(manager)
        system.install_system(
            manager
        )

        profile = Profile(self.xml_state)

        defaults = Defaults()
        defaults.to_profile(profile)

        setup = SystemSetup(
            self.xml_state,
            self.command_args['--description'],
            self.command_args['--root']
        )
        setup.import_shell_environment(profile)

        setup.import_description()
        setup.import_overlay_files()
        setup.call_config_script()
        setup.import_image_identifier()
        setup.setup_groups()
        setup.setup_users()
        setup.setup_keyboard_map()
        setup.setup_locale()
        setup.setup_timezone()

        system.pinch_system(
            manager
        )
Beispiel #44
0
from game import Game
from player import Player
from shop import Shop
from help import Help

"""colour text"""
def red(text): print("\033[91m {}\033[00m" .format(text)),
def purple(text): print("\033[95m {}\033[00m" .format(text)),
def yellow(text): print("\033[93m {}\033[00m" .format(text)),

print(chr(27) + "[2J")
player_name = input('What is your name?\n')
player = Player(player_name)
game = Game(player)
fight = Fight(player, game)
help = Help()
shop = Shop(player, game)
print(chr(27) + "[2J")
red("\nWelcome, %s" % player_name)

while True:
    game.info()
    choice = input()
    print()
    print(chr(27) + "[2J")
    print()
    if choice == '1':
        if (player.walk() == 1):
            fight.encounter()
    elif choice == '2':
        player.rest()
Beispiel #45
0
__author__ = 'jared'

from board import Board
from cell_generation import Generate
from help import Help

if __name__ == "__main__":


   creator = Generate()
   title = Help()

   title.title()
   title.rules()

   creator.world_countdown()