Esempio n. 1
0
    def __init__(self):
        simplepanel.applet.Applet.__init__(self)

        self.windows = Windows(ICON_SIZE)
        self.windows.connect('windows_changed', lambda *x: self.draw())

        self.connect('click', self.click_cb)

        self.draw()
Esempio n. 2
0
class WindowListApplet(simplepanel.applet.Applet):

    def __init__(self):
        simplepanel.applet.Applet.__init__(self)

        self.windows = Windows(ICON_SIZE)
        self.windows.connect('windows_changed', lambda *x: self.draw())

        self.connect('click', self.click_cb)

        self.draw()


    def click_cb(self, source, x, y):
        window = self._get_window_at_coord(x)
        self.windows.toggle_window(window)


    def _get_window_at_coord(self, x):
        position = 0

        for window in self.windows.on_current_desktop:
            if window.icon is not None:
                position += window.icon.get_width() + PADDING
                if x < position:
                    return window


    def render(self, ctx):

        position = PADDING
        for window in self.windows.on_current_desktop:
            icon = window.icon
            if icon is not None:
                height = icon.get_height()
                ctx.set_source_pixbuf(icon, position, (self.allocation[1] - height)/2)
                ctx.paint()

                position += icon.get_width() + PADDING



    def allocate(self, height):
        width = PADDING

        for window in self.windows.on_current_desktop:
            print window.title
            icon = window.icon
            if icon is not None:
                width += icon.get_width() + PADDING

        self.set_allocation(width, height)

        return self.get_allocation()
Esempio n. 3
0
def container():
    c = Config()
    database, websites = c.get_configuration()

    i = Initialize()
    browsers, dns_types = i.get_initialization()

    operation_system = platform.system()
    if operation_system == "Windows":
        system = Windows()
    elif operation_system == "Linux":
        system = Linux()

    resolver, recursive = system.get_dns_metadata()

    return database, websites, browsers, dns_types, resolver, recursive, system
Esempio n. 4
0
 def build_boot_image(node, template, net_template):
     if node['os'] in [
             "centos7.3", "centos7.4", "redhat7.2", "rhvh4.1", "redhat7.5",
             "centos7.5"
     ]:
         return Kickstart.build_boot_image(node, template)
     if node['os'] in ["esxi6.0", "esxi6.5", "esxi6.7"]:
         return VMware.build_boot_image(node, template)
     if node['os'] in ["win2012r2", "win2016"]:
         return Windows.build_boot_image(node, template, net_template)
     return 1, "no os is built! for os %s and node {0}".format(
         node['os'], node['name'])
Esempio n. 5
0
class MobileShop:
    iphone = None
    samsung = None
    windows = None

    def __init__(self):
        self.iphone = IPhone()
        self.samsung = Samsung()
        self.windows = Windows()

    def samsungSale(self):
        self.samsung.modelName()
        self.samsung.price()

    def iphoneSale(self):
        self.iphone.modelName()
        self.iphone.price()

    def windowsSale(self):
        self.windows.modelName()
        self.windows.price()
Esempio n. 6
0
 def build_boot_image(node, template, net_template):
     """
     template is the kickstart, answer, preseed file
     net_template is the network file for windows and the initrd for ubuntu
     """
     if node['os'] in ["centos7.3", "centos7.4", "redhat7.2", "rhvh4.1", "redhat7.5", "centos7.5"]:
         return Kickstart.build_boot_image(node, template)
     if node['os'] in ["esxi6.0", "esxi6.5", "esxi6.7"]:
         return VMware.build_boot_image(node, template)
     if node['os'] in ["ubuntu18.04"]:
         return Ubuntu.build_boot_image(node, template, net_template)
     if node['os'] in ["win2012r2", "win2016"]:
         return Windows.build_boot_image(node, template, net_template)
     return 1,  "no os is built! for os %s and node {0}".format(node['os'], node['name'])
def detect_vehicle(image, show_heat=False):
    windows = Windows(image.shape).windows
    # Uncomment the following line if you extracted training
    # data from .png images (scaled 0 to 1 by mpimg) and the
    # image you are searching is a .jpg (scaled 0 to 255)
    normalized_image = image.astype(np.float32) / 255
    hot_windows = search_windows(normalized_image,
                                 windows,
                                 model["svc"],
                                 model["scaler"],
                                 color_space=model["color_space"],
                                 spatial_size=model["spatial_size"],
                                 hist_bins=model["hist_bins"],
                                 orient=model["orient"],
                                 pix_per_cell=model["pix_per_cell"],
                                 cell_per_block=model["cell_per_block"],
                                 hog_channel=model["hog_channel"],
                                 spatial_feat=model["spatial_feat"],
                                 hist_feat=model["hist_feat"],
                                 hog_feat=model["hog_feat"])

    hot_windows = remove_false_pos(hot_windows)

    heat = np.zeros_like(image[:, :, 0]).astype(np.float)
    # Add heat to each box in box list
    heat = add_heat(heat, hot_windows)

    # Apply threshold to help remove false positives
    heat = apply_threshold(heat, 1)

    # Visualize the heatmap when displaying
    heatmap = np.clip(heat, 0, 255)
    # Find final boxes from heatmap using label function
    labels = label(heatmap)
    draw_img = draw_labeled_bboxes(image, labels)

    if show_heat:
        heatmap = np.clip(heat, 0, 255)
        return draw_img, heatmap, hot_windows
    else:
        return draw_img
Esempio n. 8
0
def run_game():
    pygame.init()  #初始化
    st = Settings()
    screen = pygame.display.set_mode(st.setmode)  #500*600的屏幕
    pygame.display.set_caption('TicTacToe')  #标题

    image = pygame.image.load('materials/chessboard.bmp')  #载入棋盘
    chess = Chess()
    bigchess = BigChess()
    retract_button = Button(screen, (170, 50, 150, 40), text='Retract')  #悔棋按钮
    replay_button = Button(screen, (170, 110, 150, 40), text='Replay')  #重玩按钮
    windows = Windows(screen, 'Replay?', 'Yes', 'No', 150, 200)
    while True:
        screen.fill(st.bg_color)  #背景色
        screen.blit(image, st.top_left_corner)  #在棋盘左上角位置绘制棋盘,注意跟棋盘的中心位置有关

        f.check_keydown(chess, bigchess, windows, screen, st, retract_button,
                        replay_button)  #检测鼠标按动

        retract_button.draw_button()  #绘制悔棋按钮
        replay_button.draw_button()  #绘制重玩按钮
        f.draw(chess, bigchess, screen, windows, st)  #绘制棋子,框等
        pygame.display.update()  #更新屏幕
Esempio n. 9
0
images = [
    Ubuntu('19.04', 'x86_64'),
    Ubuntu('19.04', 'arm32v7'),
    Ubuntu('18.04', 'x86_64'),
    Ubuntu('18.04', 'arm32v7'),
    Ubuntu('16.04', 'x86_64'),
    Ubuntu('16.04', 'arm32v7'),
    Debian('stretch', 'x86_64'),
    Debian('stretch', 'arm32v7'),
    Debian('buster', 'x86_64'),
    Debian('buster', 'arm32v7'),
    Fedora('29', 'x86_64'),
    Fedora('30', 'x86_64'),
    Fedora('31', 'x86_64'),
    Windows('x86_64', 'static'),
]

travis = Travis(images)


def create_images():
    for image in images:
        image.write()
    print('Dockerfiles generated in images/\n')


def filter_images(filters):
    if not filters:
        return images
Esempio n. 10
0
    def __init__(self):

        # *************** основное window ***************

        self.win_width = settings.WIDTH_WIN  # Ширина окна

        self.win_height = settings.HEIGHT_WIN  # Высота окна

        self.win_display = (self.win_width, self.win_height)  # Компановка

        self.timer = pygame.time.Clock()  # Таймер кадров

        # *************** инициализация объектов ***************

        self.left = self.right = self.up = self.down = self.space = False

        self.exit_ = True  # флаг для выхода

        self.windows = Windows()  # инициализируем Windows

        self.TARGET = pygame.USEREVENT

        self.level1 = Level(settings.LEVEL_1)  # Инициализируем level1

        self.level1.load_level()

        self.player = Player(
            self.level1.ret_A())  # инициализируем Tank по карте

        self.enemy = Enemy(self.level1.ret_B())

        self.platforms = self.level1.ret_tiles()

        self.end = (self.player.ret_topleft()[0] / 32,
                    self.player.ret_topleft()[1] / 32)

        self.start = (self.level1.ret_B()[0] / 32, self.level1.ret_B()[1] / 32)

        # *************** блоки спрайтов ***************

        self.block_list = pygame.sprite.Group(
        )  # Это список спрайтов. Каждый блок добавляется в этот список.

        self.all_sprites_list = pygame.sprite.Group(
        )  # # Это список каждого спрайта. Все блоки, а также блок игрока.

        self.bullet_list = pygame.sprite.Group()  # тес массив спрайтов пули

        self.block_list_destruct = pygame.sprite.Group(
        )  # Массив разрушающихся блоков

        self.block_list_undestruct = pygame.sprite.Group(
        )  # Массив неразрушающихся блоков

        self.block_list.add(self.platforms)

        self.all_sprites_list.add(self.player, self.enemy)

        self.walls = []

        for block in self.block_list:
            x, y = block.rect.topleft

            self.walls.append((x / 32, y / 32))

            if block.destructibility:

                self.block_list_destruct.add(block)

            else:

                self.block_list_undestruct.add(block)
Esempio n. 11
0
class AppGame():
    def __init__(self):

        # *************** основное window ***************

        self.win_width = settings.WIDTH_WIN  # Ширина окна

        self.win_height = settings.HEIGHT_WIN  # Высота окна

        self.win_display = (self.win_width, self.win_height)  # Компановка

        self.timer = pygame.time.Clock()  # Таймер кадров

        # *************** инициализация объектов ***************

        self.left = self.right = self.up = self.down = self.space = False

        self.exit_ = True  # флаг для выхода

        self.windows = Windows()  # инициализируем Windows

        self.TARGET = pygame.USEREVENT

        self.level1 = Level(settings.LEVEL_1)  # Инициализируем level1

        self.level1.load_level()

        self.player = Player(
            self.level1.ret_A())  # инициализируем Tank по карте

        self.enemy = Enemy(self.level1.ret_B())

        self.platforms = self.level1.ret_tiles()

        self.end = (self.player.ret_topleft()[0] / 32,
                    self.player.ret_topleft()[1] / 32)

        self.start = (self.level1.ret_B()[0] / 32, self.level1.ret_B()[1] / 32)

        # *************** блоки спрайтов ***************

        self.block_list = pygame.sprite.Group(
        )  # Это список спрайтов. Каждый блок добавляется в этот список.

        self.all_sprites_list = pygame.sprite.Group(
        )  # # Это список каждого спрайта. Все блоки, а также блок игрока.

        self.bullet_list = pygame.sprite.Group()  # тес массив спрайтов пули

        self.block_list_destruct = pygame.sprite.Group(
        )  # Массив разрушающихся блоков

        self.block_list_undestruct = pygame.sprite.Group(
        )  # Массив неразрушающихся блоков

        self.block_list.add(self.platforms)

        self.all_sprites_list.add(self.player, self.enemy)

        self.walls = []

        for block in self.block_list:
            x, y = block.rect.topleft

            self.walls.append((x / 32, y / 32))

            if block.destructibility:

                self.block_list_destruct.add(block)

            else:

                self.block_list_undestruct.add(block)

        # *************** инициализируем pygame (получаем screen) ***************

    def init_window(self):

        pygame.init()  # Инициализация pygame

        self.screen = pygame.display.set_mode(
            self.win_display)  # Создаем окошко

        pygame.display.set_caption('Tanks')  # название шапки "капчи"

        set_timer(self.TARGET, 2000)

    # *************** обработка процессов и действий (обработка нажатий (mouse and keyboard и др.))

    def action(self):

        while self.exit_:

            self.timer.tick(60)

            # *************** обработка ***************

            for itm in pygame.event.get():

                if itm.type == pygame.KEYDOWN and itm.key == pygame.K_LEFT:
                    self.left = True

                if itm.type == pygame.KEYUP and itm.key == pygame.K_LEFT:
                    self.left = False

                if itm.type == pygame.KEYDOWN and itm.key == pygame.K_RIGHT:
                    self.right = True

                if itm.type == pygame.KEYUP and itm.key == pygame.K_RIGHT:
                    self.right = False

                if itm.type == pygame.KEYDOWN and itm.key == pygame.K_UP:
                    self.up = True

                if itm.type == pygame.KEYUP and itm.key == pygame.K_UP:
                    self.up = False

                if itm.type == pygame.KEYDOWN and itm.key == pygame.K_DOWN:
                    self.down = True

                if itm.type == pygame.KEYUP and itm.key == pygame.K_DOWN:
                    self.down = False

                if itm.type == pygame.KEYDOWN and itm.key == pygame.K_SPACE:
                    self.space = True

                if itm.type == pygame.KEYUP and itm.key == pygame.K_SPACE:
                    self.shot_bull_game()
                    self.space = False

                if (itm.type
                        == pygame.QUIT) or (itm.type == pygame.KEYDOWN
                                            and itm.key == pygame.K_ESCAPE):
                    sys.exit(0)

            self.draw_game()

            self.update_game()

    # *************** отобрыжение процессов ***************

    def draw_game(self):

        self.windows.draw_windows(self.screen)  # рисуем окна

        self.block_list.draw(self.screen)

        self.bullet_list.draw(self.screen)

        self.all_sprites_list.draw(self.screen)

        pygame.display.update()  # обновление и вывод всех изменений на экран

    # *************** player shot ***************

    def shot_bull_game(self):

        self.player.shot_bull()

        self.bullet_list.add(self.player.ret_bull())

    # *************** destroy bullet ***************

    def destroy_bull_game(self):

        # print ('start', len(self.block_list))

        pygame.sprite.groupcollide(self.block_list_destruct, self.bullet_list,
                                   True, True)

        pygame.sprite.groupcollide(self.block_list_undestruct,
                                   self.bullet_list, False, True)

        self.player.del_bull()  # проверка выхода пули за экран и удаление

    # *************** update ***************

    def update_game(self):

        self.player.tank_update(self.left, self.right, self.up, self.down,
                                self.space, self.block_list)

        # self.enemy.enemy_move(self.path)

        self.destroy_bull_game()

        self.player.bull_move()

    # *************** удаление данных (destroy data here) ***************

    def end_pygame():

        pygame.quit()

    # *************** ЗАПУСК ИГРЫ ***************

    def play_game(self):

        self.init_window()

        self.action()

        self.end_pygame()
Esempio n. 12
0
def configure(vee):
	from modes import Modes
	from windows import Windows
	Modes.attach(vee)
	Windows.attach(vee)
Esempio n. 13
0
def parse_commands(byte_msg):

    if '/' not in str(byte_msg):
        message = b"[msg]=" + byte_msg
        out_message_queue.put(message)
    if '/quit' in str(byte_msg):
        print('Bye.')
        exit(1)


def get_input():
    while True:
        h, w = windows.text_window.getmaxyx()
        try:

            new_msg = windows.text_window.getstr(h - 2, w - w + 3, 90)
            parse_commands(new_msg)
            windows.refresh_text_window()

        except KeyboardInterrupt:
            print('Bye.')
            exit(1)


if __name__ == "__main__":
    windows = Windows(curses.initscr())  # draw curses windows
    refresh_chat_window()                # spawn a thread to keep chat window updated
    connect_socket('127.0.0.1', 5000)    # spawn two thread connections, one sender, one receiver
    get_input()                          # loop waiting for user input
Esempio n. 14
0
def map_i_to_up():
    print("Hello?")
    Windows.unlock_keyboard()
    Windows.press_key("up")
    Windows.release_key("up")
    Windows.lock_keyboard()
Esempio n. 15
0
from ingredient import Ingredient
from food import Food
from foodlist import FoodList
from ingredientlist import IngredientList
from windows import Windows
import pickle
import easygui as ui
import tkinter as tk

food_list = FoodList()
ingredient_list = IngredientList()

# Step 1: Load the food list
food_list.load_food(
)  # In case there is no food list, an empty list gets loaded
ingredient_list.load_ingredients()

windows = Windows(food_list, ingredient_list)

# Step 2: Starting the main loop and showing the options to the user
win = windows.window
win.mainloop()
Esempio n. 16
0
 def __init__(self):
     self.iphone = IPhone()
     self.samsung = Samsung()
     self.windows = Windows()