Пример #1
0
    def __meta_logger__(self,
                        l_f=str(),
                        l_db=str(),
                        pid=str(),
                        t=1,
                        condition="[+] Running"):

        self.Logger = Logger(log_file=l_f, log_db=l_db)

        self.ir = Info_retriever()
        s_bar = Status_bar(comment=pid + " program running")

        while True:
            try:
                status = self.ir.check_if_alive(pid)
                if status != condition:
                    self.Logger.log_save(status)
                    break

                if not self.silent:
                    s_bar.rotate()

                time.sleep(int(t))

            except KeyboardInterrupt:
                exit()

            except EOFError:
                pass
Пример #2
0
    def receiver(self, code_appender=list()):
        #self.sub_logger("[+] receiver start") <-unash for more logs

        s_bar = Status_bar("receiving")

        while code_appender == list():
            if not self.silent:
                s_bar.b_comment = " " + time.ctime() + " "
                s_bar.rotate()

            code_appender = self.receive(self.username, self.password)

        if code_appender != list(): return code_appender
Пример #3
0
 def __init__(self):
     self.file = str()
     self.text = str()
     self.len_input = 1
     self.sb = Status_bar()
     self.silent = False
Пример #4
0
class Text_manipulator():
    def __init__(self):
        self.file = str()
        self.text = str()
        self.len_input = 1
        self.sb = Status_bar()
        self.silent = False

    def Write_new(self, t_file, text):
        f = open(t_file, 'w')
        f.write(text)
        f.close

    def Read(self, t_file):
        try:
            f = open(t_file, 'r')
            text = f.read()
            f.close
        except:
            raise
        return text

    def Read_lines(self, t_file, segments=list()):  #segments = [[int1,int2]]
        try:
            f = open(t_file, 'r')
            text = list()
            for okazaki in segments:
                for line in f[okazaki[0]:okazaki[1]]:
                    text.append(line)  #line mantain the nl char
            return text

        except:
            raise

    def Write_add(self, t_file, text):
        old = self.Read(t_file)
        text = old + text
        self.Write_new(t_file, text)

    def differences(self, str_list=list()):
        str_list.sort(key=len)
        for s in str_list:
            for s in str_list[str_list.index(s):]:
                pass
        pass

    def Read_as_input_old(self, t_file=str()):

        self.sb.comment = "waiting for input in " + str(t_file)

        first = True
        while True:
            if not self.silent:
                self.sb.rotate()

            raw = self.Read(t_file).split("\n")
            if first:
                first = False
                self.len_input = len(raw)
                self.last_line = raw[-1]
            else:

                if len(raw) > self.len_input:
                    #print "len_raw" + str(len(raw))
                    #print "len_input" + str(self.len_input)
                    lasts = len(raw) - self.len_input + 1

                    self.len_input = len(raw)
                    self.last_line = raw[-1]

                    if len(raw) != 0:
                        last_lines = str()
                        for line in raw[-lasts:]:
                            last_lines += line + "\n"

                        return last_lines[:-1]
                elif len(raw) == self.len_input:
                    if self.last_line != raw[-1]:
                        self.last_line = raw[-1]

                        return self.last_line

                #elif len(raw) < self.len_input:
                #self.len_input = len(raw)
    def simple_diff_equal(self, a=str(), b=str()):
        if len(a) == len(b):
            i = 0
            new_chars = str()
            for char in a:
                if char != b[i]:
                    new_chars += char
                i += 1

            return new_chars

    def simple_diff(self, a=str(), b=str()):
        if a != b:
            if len(a) > len(b):
                return self.simple_diff_equal(a[:len(b)], b) + a[len(b):]

            if len(a) < len(b):
                pass

            if len(a) == len(b):
                return self.simple_diff_equal(a, b)
        else:
            pass

        return None

    def Read_as_input(self, t_file=str()):
        self.sb.comment = "waiting for input in " + str(t_file)
        older = self.Read(t_file)
        while True:

            result = self.simple_diff(self.Read(t_file), older)
            if result:
                return result
            else:
                if not self.silent:
                    self.sb.rotate()

    def Write_as_output(self, t_file, text):
        try:
            self.Write_add(t_file, text)
        except:
            try:
                self.Write_new(t_file, text)
            except:
                raise

    def Read_and_print(self, t_file):
        while True:
            try:
                print self.Read_as_input(t_file)
            except KeyboardInterrupt:
                break
            except:
                raise
Пример #5
0
bullets_group = []

#Персонаж, врги и друзья
enemies = friends = 0

#Создание меню
pause = Pause(punkts1, "Pause")
menu = Menu(punkts, "Battle city")
options = Options(punkts2, 'Options')
u_win = End_of_game(punkts3, "You win!")
u_lose = End_of_game(punkts4, 'Game over')
level_choose = Level_choose(punkts5, 'Choose level')
current_diff = 0

#Создание строки состояния
status_bar = Status_bar(0, 0)

#Создание Таймера
timer = Timer()

#Создание уровня
max_enemies = 0
spavned_enemies = 0
total_enemies = 0
stage = 0
bricks_group = []
enemy_spavner_group = []
level_num = 0
lvl_w = lvl_h = 0