コード例 #1
0
ファイル: main.py プロジェクト: PhonPhey/ritualist
def main():
    ''' Main function '''
    # Открываем окно с задаными параметрами высоты, ширины и заголовка
    arcade.open_window(base_const.WIN_TITLE, base_const.WIN_WIDTH,
                       base_const.WIN_HEIGHT)

    arcade.set_background_color(
        base_const.WIN_BACKGROUND_COLOR)  # Задаём цвет фона окна

    _gen = gen.Gen()  # Создаём экземпляр класса генераторов

    log.logging.info('Цвет фона задан')
    log.logging.info('Экземпляр класса генераторов создан')

    arcade.start_render()  # Начинаем рендер в открытом окне

    log.logging.info('Начат рендер в открытом окне ')

    _gen.build_map(_gen.rand_map_gen())  # генерируем ,cтроим и рисуем карту
    tsc.ALL_SPRITES[1].draw()

    log.logging.info('Генерация и прорисовка карты')

    arcade.finish_render()  # Заканчиваем рендер в открытом окне

    log.logging.info('Рендер закончен успешно')

    log.logging.info('Приложение запущено успешно')

    arcade.run()  # Запускаем приложение
コード例 #2
0
def get_douban_descr(url):

    if type(url) == str:
        if url.find('imdb') >= 0:
            imdb_link = re.search('.*imdb.com/title/(tt\d{5,9})', url)
            url = {'site': 'douban', 'sid': imdb_link.group(1)}
    gen_ = gen.Gen(url).gen(_debug=True)
    if gen_["success"]:
        descr = gen_["format"]

        old_str = 'https://img3.doubanio.com/view/photo/l_ratio_poster/public/'
        new_str = 'https://img1.doubanio.com/view/photo/l_ratio_poster/public/'

        descr = re.sub(old_str, new_str, descr)
        # print(descr)
        return descr
    else:
        return 'error'
コード例 #3
0
ファイル: owner.py プロジェクト: Navpreet2289/code
 def gen_sftp_objects(self, name):
     """
     Create SFTP Objects based on config files. store in Owner.
     """
     self.json = json.load(self.json_handle)
     for account in self.json:
         if account['name'] not in self.log.json:
             self.log.json[account['name']] = None
         self.transport[account['name']] = gen.Gen(
             account['host'],
             account['username'],
             account['password'],
             account['port'],
             account['name'],
             account['remote_directory'],
             account['local_directory'],
             account['action'],
             account['regex'],
             self.log.json[account['name']],
             verbose=True)
         self.transport[account['name']].later_files()
コード例 #4
0
class MainApp(App):
    my_osc = osc.Oscilloscope()
    my_gen = gen.Gen()
    bode = bode.Bode()

    my_screenmanager = ScreenManager()
    container_box = ContainerBox(name='screen1')
    bode_menu = BodeMenu(name='screen2')
    meas_menu = MeasMenu(name='screen3')
    end_menu = EndMenu(name='screen4')

    ## Data obtained from menus
    data = dict()

    def build(self):

        self.bode_menu.set_main_ref(self)
        self.container_box.set_main_ref(self)
        self.meas_menu.set_main_ref(self)
        self.end_menu.set_main_ref(self)

        self.my_screenmanager.add_widget(self.container_box)
        self.my_screenmanager.add_widget(self.bode_menu)
        self.my_screenmanager.add_widget(self.meas_menu)
        self.my_screenmanager.add_widget(self.end_menu)

        return self.my_screenmanager

    def connect(self, osc, gen, filename):
        m = 10**6
        self.data["filename"] = filename

        self.my_osc.connect(osc)
        self.my_gen.connect(gen)

        self.bode.set(self.my_osc, self.my_gen)
        self.bode.start(self.data["start_freq"], self.data["end_freq"],
                        self.data["points"], self.data["v_input"],
                        self.data["time_delay"], self.data["res"])

    def set_data(self, key, content):
        self.data[key] = content

    def get_data(self, key):
        return self.data[key]

    def update(self, dt):
        if self.bode.update():
            print("Fininshed ")
            self.my_screenmanager.current = 'screen4'
            self.bode.save_csv(self.data["filename"])

        self.meas_menu.update(self.bode.get_data())

    def cancel(self):
        print("Cancelling")
        self.bode.cancel()
        self.my_screenmanager.current = 'screen2'

    def restart(self):
        self.bode.cancel()
        self.my_screenmanager.current = 'screen1'
コード例 #5
0
            print('đã xác nhập')
            self.population.pop = self.Selection()
            print('đã chọn thế hệ tiếp')
            self.population.update_rank()
            print('đã đánh giá thế hệ')
            self.iteration += 1
        best = self.population.getBestIndiOfTask(self.listTask[0])
        for i in best.chromosome:
            print(i.number)
        # đến đây chỉ cần chích xuất ra kết quả


#-----------------------------------------------
task1 = task.Task(6)
task2 = task.Task(10)
listTask = [task1, task2]
# đặt các đỉnh
set_of_city = []
f = open(
    "C:\\Users\\Laptop NamPhong\\Desktop\\MFO_TSP\\data\\tsp\\berlin52.tsp")
for i in range(6):
    a = f.readline()
for i in range(10):
    b = f.readline()
    b = list(b.split("\n"))
    c = [int(float(i)) for i in list(b[0].split(" "))]
    city = gen.Gen(c[0], c[1], c[2])
    set_of_city.append(city)
mfea = MultiTasking(listTask, 100, 0.3, set_of_city)
mfea.run()
コード例 #6
0
            if('for ' in line):
                in_loop = 1
            if in_loop == 0:
                file.write(line + "\n")  
            else:
                if (('for' in line) or ('if ' in line) or (line.isspace())): 
                    file.write(line + "\n")  
                else:
                    file.write("xxyyyx = 1" + "\n")      
        file.close() 
    except IOError:
        print 'Coulnt save to file'
    i = i+1
    try:
        file = open("tmp/geo.txt", 'w')
        for item in geo:
            file.write(str(item[0]) + " " + str(item[1]) + "\n")
        file.close()
    except IOError:
        print 'Coulnt save to file'

print str(count_loop) + ' loops found.';


s = 0
if len(sys.argv) > 3:
    if('--scc' in sys.argv[3]):
        s = 1
        
gen.Gen(sys.argv[1],s,permute);
コード例 #7
0
ファイル: main.py プロジェクト: newtonis/INFORMES_ASSD
#
# micro = 10**(-6)
# #
# osc1 = osc.Oscilloscope()
# # #
# osc1.connect("USB0::0x0957::0x1725::MY49110441::INSTR")

#osc1.set_scale_Y(100, "1")

#print(osc1.get_amplitude("1") )
#osc1.set_scale_X( 100 * micro )
# end = 0
# while not end:
#     if osc1.update() == 1:
#         end = 1
# osc1.close()
k = 10**3

gen1 = gen.Gen()
gen1.connect()

gen1.set_sine(10 * k, 5)

# import osc
# #
# osc1 = osc.Oscilloscope()
# osc1.connect()
#
# print(osc1.ratio2to1())
# #
# osc1.close()