Пример #1
0
    def __init__(self, prt):
        self._parent = prt
        self._list = [u"screencapture", u"shell", u"transfers"]
        self._sessions = False
        self._cmps = {}
        self._visible_cmps = {}
        self._screen_w = 0
        self._screen_h = 0
        self._dlg_w = 25
        self._dlg = gdi.Window(gdi.WINDOW_TYPE_POPUP)
        self._dlg.set_background("ffaa33")
        self._pnl = gdi.Panel()
        self._pnl.set_position(1, 1)
        self._pnl.set_size(self._dlg_w, 24)
        self._pnl.set_background("313536")
        self._dlg.add_component(self._pnl)
        implogo = gdi.ImagePanel()
        implogo.set_position(4, 4)
        implogo.set_filename(images.get_image(u"logo16x16.bmp"))
        self._pnl.add_component(implogo)

        for k in self._list:
            self._visible_cmps[k] = False
            self._cmps[k] = gdi.ImagePanel()
            self._cmps[k].set_filename(
                images.get_image(u"activities_" + k + u".bmp"))
            self._dlg.add_component(self._cmps[k])

        self._sessions_last_update = self._sessions
        self._visible_cmps_last_update = self._visible_cmps.copy()
        self._dlg.set_action(self.on_action)
Пример #2
0
    def slice_charset(self):
        self.charset_list = []
        self.charset_lib = {}
        charset = images.get_image(self.settings["charset"])
        charset_rect = charset.get_rect()
        width = self.settings["tile_size"].width
        height = self.settings["tile_size"].height
        number_of_horizontal_slices = charset_rect.width / width
        number_of_vertical_slices = charset_rect.height / height

        for v in range(0, number_of_vertical_slices):
            for h in range(0, number_of_horizontal_slices):
                subsurface = charset.subsurface(
                    pygame.Rect(width * h, height * v, width, height))

                tile_rect = subsurface.get_rect()
                scale = game.settings.get('screen')["scale"]
                subsurface = pygame.transform.scale(
                    subsurface,
                    (tile_rect.width * scale, tile_rect.height * scale))
                self.charset_list.append(subsurface)

        self.charset_lib["default"] = self.charset_list[60]
        debug(
            self.charset_list, "Created " +
            str(number_of_horizontal_slices * number_of_vertical_slices) +
            " Tiles from " + self.settings["charset"])
Пример #3
0
    def slice_charset(self):
        self.charset_list = []
        self.charset_lib = {}
        charset = images.get_image(self.settings["charset"])
        charset_rect = charset.get_rect()
        width = self.settings["tile_size"].width
        height = self.settings["tile_size"].height
        number_of_horizontal_slices = charset_rect.width / width
        number_of_vertical_slices = charset_rect.height / height

        for v in range(0, number_of_vertical_slices):
            for h in range(0, number_of_horizontal_slices):
                subsurface = charset.subsurface(pygame.Rect(
                    width * h, height * v,
                    width, height
                ))

                tile_rect = subsurface.get_rect()
                scale = game.settings.get('screen')["scale"]
                subsurface = pygame.transform.scale(subsurface, (tile_rect.width * scale, tile_rect.height * scale))
                self.charset_list.append(subsurface)

        self.charset_lib["default"] = self.charset_list[60]
        debug(self.charset_list, "Created " +
              str(number_of_horizontal_slices * number_of_vertical_slices) +
              " Tiles from " + self.settings["charset"])
Пример #4
0
    def Render(self, screen):
        ## render our charactor

        screen.blit(get_image("images/background.png"), (0, 0))
        # screen.fill((40, 100, 255))
        self.charactor.render(screen)
        for i in self.enemies:
            i.render(screen)
Пример #5
0
 def draw_object(self, obj, canv):
     """
     Рисует объект obj на canv
     Возвращает id на канвасе
     """
     if canv == 'field':
         canvas_id = self.field.create_image(obj.x,
                                             obj.y,
                                             anchor=NW,
                                             image=img.get_image(
                                                 obj.img_id))
     elif canv == 'interface':
         canvas_id = self.interface.create_image(obj.x,
                                                 obj.y,
                                                 anchor=NW,
                                                 image=img.get_image(
                                                     obj.img_id))
     return canvas_id
Пример #6
0
        def define_image():
          if not image:
              self.image = images.get_image(images.resources["empty"])
          else:
              self.image = image

          self.image = pygame.transform.scale(self.image, (self.size.width, self.size.height))
          self.rect = pygame.Rect(self.position.x, self.position.y, self.size.width, self.size.height)
          self.color = False
Пример #7
0
def build(name, directory):
    src, tag, build_args = get_image(name)

    command = [os.path.join(directory, src), tag]
    command.extend([v for v in build_args.values()])
    print("INFO: %s: Building" % tag)
    output = subprocess.run(args=command, stdout=subprocess.PIPE)
    if output.returncode != 0:
        print("Error building container %s" % name)
        return
Пример #8
0
def load_csv(filename):
    X_meta = []
    Y_train = []
    X_images = []
    Coordinates = []

    reader = csvReader(filename)

    for row in reader.table[:100]:
        # Load image
        from images import get_image
        image = get_image(row, "google")

        # Convert image into numpy array
        from scipy.misc import fromimage
        img = fromimage(image)

        # Add numpy array to images array
        X_images.extend([img])

        # Fill coordinates array
        coordinate = [
            float(row['X_Coordinate'].replace(',', '.')),
            float(row['Y_Coordinate'].replace(',', '.')),
        ]
        Coordinates.extend([coordinate])

        # Fill metadata input array
        x = [
            # float(row['X_Coordinate'].replace(',', '.')),
            # float(row['Y_Coordinate'].replace(',', '.')),
            float(hash(row['District'])) % 100,
            float(hash(row['Street'])) % 100,
            # float(row['ZipCode']),
        ]
        X_meta.extend([x])

        # Fill output array
        y = [
            int(row['ZipCode']),
        ]
        Y_train.extend([y])

    import numpy

    Coordinates = numpy.asarray(Coordinates, dtype=numpy.float32)
    X_meta = numpy.asarray(X_meta, dtype=numpy.float32)
    X_images = numpy.asarray(X_images, dtype=numpy.float32)
    Y_train = numpy.asarray(Y_train, dtype=numpy.float32)
    X_train = [X_images, X_meta]

    print("X_images.shape", X_images.shape)
    print("Y_train.shape", Y_train.shape)

    return Coordinates, (X_train, Y_train)
Пример #9
0
def build(name):
    tag = get_image(name)

    command = ["podman", "pull", tag]
    print("INFO: %s: Pulling" % tag)
    output = subprocess.run(args=command,
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE)
    if output.returncode != 0:
        print("Error pulling container: %s" % output.stderr.decode('utf-8'))
        return
Пример #10
0
def _test_notify(e):
    if _NOTIFY_ICON["visible"]:
        #_NOTIFY_ICON["obj"].update(images.get_image("monitor_red.bmp"),u"MSG LOGO")
        _NOTIFY_ICON["obj"].destroy()
        _NOTIFY_ICON["visible"]=False
        _NOTIFY_ICON["obj"]=None        
    else:         
        _NOTIFY_ICON["obj"] = gdi.NotifyIcon(images.get_image("monitor_green.bmp"),u"MSG LOGO")
        _NOTIFY_ICON["obj"].set_object("window",e["window"])
        _NOTIFY_ICON["obj"].set_action(_test_notify_action)
        _NOTIFY_ICON["visible"]=True
Пример #11
0
def load_popos():
    """Load Privately-Owned Public Open Space (POPOS) data from popos.csv into database."""

    print "Privately-Owned Public Open Space"

    # Read popos.csv file and parse data
    for row in open("seed_data/popos.csv"):
        row = row.rstrip()

        name, address, latitude, longitude, subj, popos_type = row.split(",")[1:7]
        # restroom, description, seats, hours_type, mapid = row.split(",")[-5:]
        # seating = row.split(",")[14]

        # if name != address:
        #     name = '\n'.join([name, address])

        # if restroom != 'Y':
        #     restroom = 'N'

        image_url = get_image(name, latitude, longitude, address)
        # print name, image_url


        park = Park(park_type='popos',
                    name=name,
                    latitude=float(latitude),
                    longitude=float(longitude))

        # Add popos data to the parks db session & commit session to db
        db.session.add(park)
        db.session.commit()

        popos = Popos(park_id=park.park_id,
                      address=address,
                      popos_type=popos_type)

                    # TODO: add additional POPOS info
                      # restroom=restroom,
                      # description=description,
                      # seating=seating.capitalize(),
                      # hours=hours_type.capitalize()

        # Add popos data to the popos db session & commit session to db
        db.session.add(popos)
        db.session.commit()

        image = Image(img_park_id=park.park_id,
                      image_url=image_url)

        # Add image_url to the image db session & commit session to db
        db.session.add(image)
        db.session.commit()
    
    print "Committed to DB"
Пример #12
0
def csv_convert(filename, sort, foilsheet):
    if (os.path.isdir('{}_img'.format(os.path.splitext(filename)[0])) == 0):
        os.mkdir('{}_img'.format(os.path.splitext(filename)[0])) 
    if foilsheet:
        if (os.path.isdir('{}_foil_img'.format(os.path.splitext(filename)[0])) == 0):
            os.mkdir('{}_foil_img'.format(os.path.splitext(filename)[0])) 
    num = 0
    with open(filename, 'r') as file:
        row_count = sum(1 for row in file) - 1
    file.close()
    with open(filename, 'r') as file:
        data = csv.reader(file, delimiter=',')
        next(data)
        filename = os.path.splitext(filename)[0]
        for row in data:
            if row:
                try:
                    name = set = lang = quantity = foil = promo = ''
                    quantity = row[1]
                    name = row[2]
                    set = row[3]
                    lang = row[6]
                    foil = row[7]
                    num += 1
                except Exception as e:
                    print('Row parsing error: {}'.format(e))
                    pass
                if (set == "Friday Night Magic") or (set == "Launch Parties") or (set == "Standard Showdown Promos") or (set == "Magic Game Day") or (set == 'Magic Game Day Cards'):
                    set = 'Promo'
                    promo = True
                if set.startswith('Prerelease Events'):
                    set = set.replace('Prerelease Events: ', '')
                    set = '{} Promos'.format(set)
                if set.startswith('Magic 2'):
                    set = set.replace('Magic ', '') 
                    set = set.replace(' Core Set', '')
                    set = 'Magic {}'.format(set)
                if set.startswith('Modern Masters'):
                    set = set.replace('Edition', '')
                if set == 'Archenemy: Nicol Bolas':
                    set = 'e01'
                name = name.replace('//', '-')
                set = images.get_image(name, set, filename, sort, num, row_count)
                images.edit_image(filename, set, name, lang, foil, quantity, promo, foilsheet)
#Colors of the card could be taken from scryfall tags
#Artifact Black Green Red UBlue White
# WUBRG
# WUBR WUBG WURG WBRG UBRG
# WUB WUR WUG WBR WBG WRG UBR UBG URG BRG 
# WU WB WR WG UB UR UG BR BG RG

# BGRUW
# 
Пример #13
0
def load_popos():
    """Load Privately-Owned Public Open Space (POPOS) data from popos.csv into database."""

    print "Privately-Owned Public Open Space"

    # Read popos.csv file and parse data
    for row in open("seed_data/popos.csv"):
        row = row.rstrip()

        name, address, latitude, longitude, subj, popos_type = row.split(
            ",")[1:7]
        # restroom, description, seats, hours_type, mapid = row.split(",")[-5:]
        # seating = row.split(",")[14]

        # if name != address:
        #     name = '\n'.join([name, address])

        # if restroom != 'Y':
        #     restroom = 'N'

        image_url = get_image(name, latitude, longitude, address)
        # print name, image_url

        park = Park(park_type='popos',
                    name=name,
                    latitude=float(latitude),
                    longitude=float(longitude))

        # Add popos data to the parks db session & commit session to db
        db.session.add(park)
        db.session.commit()

        popos = Popos(park_id=park.park_id,
                      address=address,
                      popos_type=popos_type)

        # TODO: add additional POPOS info
        # restroom=restroom,
        # description=description,
        # seating=seating.capitalize(),
        # hours=hours_type.capitalize()

        # Add popos data to the popos db session & commit session to db
        db.session.add(popos)
        db.session.commit()

        image = Image(img_park_id=park.park_id, image_url=image_url)

        # Add image_url to the image db session & commit session to db
        db.session.add(image)
        db.session.commit()

    print "Committed to DB"
Пример #14
0
    def run(self):

        # Create server
        images.select_image(self)
        keypairs.select_keypair(self)
        networks.select_network(self)

        servers.create_instance(self)
        servers.check_active(self)

        # Image processing
        images.create_image(self)

        images.check_image_status(self)
        images.list_images(self)
        images.get_image(self)
        images.delete_image(self)

        if self.overall_success is True:
            exit(0)
        else:
            exit(1)
Пример #15
0
    def change_image(self, api, centermode="address"):
        # Get image
        from images import get_image
        pilImage = get_image(self.row, api, centermode)

        # Change canvas size
        self.canvas.config(width=pilImage.width, height=pilImage.height)
        self.imagesprite = self.canvas.create_image(pilImage.width / 2,
                                                    pilImage.height / 2)

        # Show image on canvas
        self.image = ImageTk.PhotoImage(pilImage)
        self.canvas.itemconfig(self.imagesprite, image=self.image)
        return self.imagesprite
Пример #16
0
def build(name, directory):
    src, tag, _ = get_image(name)

    command = [
        "lxc", "image", "import",
        os.path.join(directory, tag + ".tar.gz"), "--alias", tag
    ]
    print("INFO: %s: Importing" % tag)
    output = subprocess.run(args=command,
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE)
    if output.returncode != 0:
        print("Error importing image: %s" % output.stderr.decode('utf-8'))
        return
Пример #17
0
def load_posm():
    """Load Park & Open Space Map data from JSON into database."""

    print "Park & Open Spaces"

    # Call API and parse data
    r = requests.get('https://data.sfgov.org/resource/94uf-amnx.json')
    parks = r.json()

    for item in parks:
        if item['parkservicearea'] != "Outside SF":
            name = item.get('parkname').title()
            posm_type = item.get('parktype')
            acreage = item.get('acreage')
            zipcode = item.get('zipcode')
            try:
                coordinates = item.get('location_1').get('coordinates') # [-122.38450221, 37.73876792]
            except AttributeError:
               continue

        image_url = get_image(name, coordinates[1], coordinates[0])
        # print name, image_url


        park = Park(park_type='posm',
                    name=name,
                    latitude=coordinates[1],
                    longitude=coordinates[0])

        # Add posm data to the parks db session & commit session to db
        db.session.add(park)
        db.session.commit()

        posm = Posm(park_id=park.park_id,
                    posm_type=posm_type,
                    acreage=acreage,
                    zipcode=zipcode)

        # Add posm data to the posm db session & commit session to db
        db.session.add(posm)
        db.session.commit()

        image = Image(img_park_id=park.park_id,
                      image_url=image_url)

        # Add image_url to the image db session & commit session to db
        db.session.add(image)
        db.session.commit()
    
    print "Committed to DB"
Пример #18
0
def load_posm():
    """Load Park & Open Space Map data from JSON into database."""

    print "Park & Open Spaces"

    # Call API and parse data
    r = requests.get('https://data.sfgov.org/resource/94uf-amnx.json')
    parks = r.json()

    for item in parks:
        if item['parkservicearea'] != "Outside SF":
            name = item.get('parkname').title()
            posm_type = item.get('parktype')
            acreage = item.get('acreage')
            zipcode = item.get('zipcode')
            try:
                coordinates = item.get('location_1').get(
                    'coordinates')  # [-122.38450221, 37.73876792]
            except AttributeError:
                continue

        image_url = get_image(name, coordinates[1], coordinates[0])
        # print name, image_url

        park = Park(park_type='posm',
                    name=name,
                    latitude=coordinates[1],
                    longitude=coordinates[0])

        # Add posm data to the parks db session & commit session to db
        db.session.add(park)
        db.session.commit()

        posm = Posm(park_id=park.park_id,
                    posm_type=posm_type,
                    acreage=acreage,
                    zipcode=zipcode)

        # Add posm data to the posm db session & commit session to db
        db.session.add(posm)
        db.session.commit()

        image = Image(img_park_id=park.park_id, image_url=image_url)

        # Add image_url to the image db session & commit session to db
        db.session.add(image)
        db.session.commit()

    print "Committed to DB"
Пример #19
0
    def slice_chipset(self):
        self.terrains = []
        chipset = images.get_image(self.tileset)
        chipset_rect = chipset.get_rect()
        number_of_possible_slices = chipset_rect.width / self.tile_width

        for i in range(0, number_of_possible_slices):
            subsurface = chipset.subsurface(pygame.Rect(
                self.tile_width * i, 0, self.tile_width, chipset_rect.height
            ))
            tile_rect = subsurface.get_rect()
            scale = game.settings.get("screen")["scale"]
            subsurface = pygame.transform.scale(subsurface, (tile_rect.width * scale, tile_rect.height * scale))
            self.terrains.append(subsurface)
        debug(self.terrains, "Created " + str(number_of_possible_slices) + " Tiles from " + self.tileset)
Пример #20
0
def build(name, directory):
    src, tag, build_args = get_image(name)

    command = ["docker", "build", "-t", tag]
    if len(build_args) > 0:
        command.extend([
            "--build-arg",
            ",".join(["%s=%s" % (k, v) for k, v in build_args.items()])
        ])
    command.extend(
        ["-f",
         os.path.join(directory, src),
         os.path.join(directory, "../")])
    print("INFO: %s: Building" % tag)
    output = subprocess.run(args=command, stdout=subprocess.PIPE)
    if output.returncode != 0:
        print("Error building container %s" % name)
        return
Пример #21
0
 def move(self, obj_id, screen_x1, screen_y1, screen_x2, screen_y2,
          animation_time, cr_time):
     cr_time += ANIM_DT
     x = screen_x1 + (screen_x2 - screen_x1) * cr_time / animation_time
     y = screen_y1 + (screen_y2 - screen_y1) * cr_time / animation_time
     self.objects[obj_id].set_coords(x, y)
     self.field.delete(self.objects[obj_id].canvas_id)
     self.objects[obj_id].canvas_id = self.field.create_image(
         self.objects[obj_id].x,
         self.objects[obj_id].y,
         anchor=NW,
         image=img.get_image(self.objects[obj_id].img_id))
     if cr_time <= animation_time:
         self.root.after(
             ANIM_DT,
             lambda: self.move(obj_id, screen_x1, screen_y1, screen_x2,
                               screen_y2, animation_time, cr_time))
     else:
         self.bind_all()
Пример #22
0
 def draw_action_bar(self):
     x0 = window_width / 2 - len(sb.spell_book) / 2 * (32 + 8)
     self.action_bar_id = self.interface.create_rectangle(
         x0,
         55 + 32,
         x0 + 2 * len(sb.spell_book) / 2 * (32 + 8),
         55,
         outline='red')
     spell_img = Object()
     spell_img.img_id = 'walk'
     spell_img.x = x0
     spell_img.y = 55
     spell_number = Object()
     spell_number.img_id = '0'
     spell_number.x = x0 + 26
     spell_number.y = 55 + 18
     canv_id = self.draw_object(spell_img, 'interface')
     self.action_ids.append(canv_id)
     canv_id = self.draw_object(spell_number, 'interface')
     self.action_number_ids.append(canv_id)
     self.action_cursor_id = self.interface.create_image(
         x0, 55, anchor=NW, image=img.get_image('cursor'))
     for i in range(1, len(sb.spell_book)):
         x0 += (32 + 8)
         spell_img = Object()
         spell_img.img_id = sb.spell_book[i].menu_image_id
         spell_img.x = x0
         spell_img.y = 55
         spell_number = Object()
         spell_number.img_id = str(i)
         spell_number.x = x0 + 26
         spell_number.y = 55 + 18
         canv_id = self.draw_object(spell_img, 'interface')
         self.action_ids.append(canv_id)
         canv_id = self.draw_object(spell_number, 'interface')
         self.action_number_ids.append(canv_id)
Пример #23
0
    def render(self,screen):
        for bullet in self.bullets:
            bullet.move()
            screen.blit(get_image('images/bullet.png'), (bullet.x, bullet.y))

        screen.blit(get_image('images/ship.png'), (self.x, self.y))
Пример #24
0
 def chimg(self, img):
     self.image = images.get_image(images.resources[img])
Пример #25
0
    pbr = gdi.ProgressBar()
    pbr.set_position(250, 250)
    pbr.set_percent(0.4)
    ww.add_component(pbr)

    pl = gdi.Panel()
    pl.set_position(0, 0)
    pl.set_size(90, ww.get_height())
    pl.set_background_gradient("83e5ff", "FFFFFF",
                               gdi.GRADIENT_DIRECTION_LEFTRIGHT)
    ww.add_component(pl)

    imp = gdi.ImagePanel()
    imp.set_position(200, 280)
    imp.set_filename(images.get_image("logo32x32.bmp"))
    ww.add_component(imp)

    pb = gdi.Panel()
    pb.set_position(0, ww.get_height() - 55)
    pb.set_size(ww.get_width(), 55)
    ww.add_component(pb)

    b1 = gdi.Button()
    b1.set_text("Message")
    b1.set_position(10, 10)
    b1.set_action(_test_other_window)
    pb.add_component(b1)

    b2 = gdi.Button()
    b2.set_text("Close")
Пример #26
0
 def get_ico_file(self, name):
     return images.get_image(name + ".ico")
Пример #27
0
 def __init__(self):
     self.image = get_image('images/enemy1.png')
     pass
Пример #28
0
def build(name, directory):
    tag, ro, wr = get_image(name)

    # Pull image and mount its fs with buildah
    container = pull(tag)
    if container is None:
        return

    image_info = get_info(tag)
    if image_info is None:
        return

    mount_path = mount(container)
    if mount_path is None:
        rm(container)
        clean(tag)
        return

    image_dir = os.path.join(directory, tag)

    if os.path.exists(image_dir):
        print("INFO: Already an image with this name, removing...")
        shutil.rmtree(image_dir, ignore_errors=True)

    print("INFO: Copying editable rootfs")
    rootfs = os.path.join(image_dir, 'rootfs')
    os.makedirs(rootfs)
    for d in wr:
        src = os.path.join(mount_path, d)
        dst = os.path.join(rootfs, d)
        # For some reason `shutil.copytree` hangs on some directories
        command = "cp -r %s %s" % (src, dst)
        output = subprocess.run(args=command.split(" "),
                                stdout=subprocess.PIPE)
        if output.returncode != 0:
            print("Error copying %s to %s" % (src, dst))
            print("INFO: Unmounting container filesystem")
            umount(container)

            print("INFO: Removing temporary container")
            rm(container)

            print("INFO: Removing temporary container image")
            clean(tag)
            return

    print("INFO: Copying read-only rootfs")
    ro_rootfs = os.path.join(image_dir, 'ro-rootfs')
    os.makedirs(ro_rootfs)
    for d in ro:
        src = os.path.join(mount_path, d)
        dst = os.path.join(ro_rootfs, d)
        # For some reason `shutil.copytree` hangs on some directories
        command = "cp -r %s %s" % (src, dst)
        output = subprocess.run(args=command.split(" "),
                                stdout=subprocess.PIPE)
        if output.returncode != 0:
            print("Error copying %s to %s" % (src, dst))
            print("INFO: Unmounting container filesystem")
            umount(container)

            print("INFO: Removing temporary container")
            rm(container)

            print("INFO: Removing temporary container image")
            clean(tag)
            return
        os.symlink(os.path.join('mnt', d), os.path.join(rootfs, d))

    print("INFO: Saving command")
    cmd = image_info["OCIv1"]["config"]["Cmd"][2]
    cmd_path = os.path.join(image_dir, 'CMD')
    with open(cmd_path, 'w+') as f:
        f.write(cmd)
        f.close()

    print("INFO: Unmounting container filesystem")
    umount(container)

    print("INFO: Removing temporary container")
    rm(container)

    print("INFO: Removing temporary container image")
    clean(tag)
Пример #29
0
 def set_action(self, action_number):
     x = window_width / 2 - len(
         sb.spell_book) / 2 * (32 + 8) + action_number * (32 + 8)
     self.interface.delete(self.action_cursor_id)
     self.action_cursor_id = self.interface.create_image(
         x, 55, anchor=NW, image=img.get_image('cursor'))