Example #1
0
    def refresh(self):
        x = self.width / 2
        left = 5
        while not self.is_terminated():
            try:
                eth = self.get_ip_address('eth0')
            except:
                eth = 'none'
            try:
                wifi = self.get_ip_address('wlan0')
            except:
                wifi = 'none'

            image, draw = self.get_new_image_and_canvas()
            pos = font.text(draw, (x, 3),
                            'Net', 'large', 'hcenter')
            pos = font.text(draw, (left, pos[1] - 2),
                            'eth0:', 'small')
            pos = font.text(draw, (x, pos[1] - 3),
                            str(eth), 'small', 'hcenter')
            pos = font.text(draw, (left, pos[1] - 2),
                            'wlan0:', 'small')
            pos = font.text(draw, (x, pos[1] - 3),
                            str(wifi), 'small', 'hcenter')
            self.image = image
            self.new_image_is_ready()
            time.sleep(2)
Example #2
0
    def get_clock(self):
        x = self.width / 2
        left = 5
        bar_height = 8
        measurement_time = 1

        while not self.is_terminated():
            ret = subprocess.check_output(
                'iostat -d %i 1 -y | grep %s | awk \'{print $3 " " $4}\'' %
                (measurement_time, self.disk), shell=True)
            read, write = ret.split()

            image, draw = self.get_new_image_and_canvas()
            pos = font.text(draw, (x, 0),
                            'DiskI/O', 'large', 'hcenter')

            pos = font.text(draw, (left, pos[1]),
                            'Read', 'small')
            widgets.horizontal_bar(draw, left, pos[1],
                                   self.width - left, pos[1] + bar_height,
                                   float(read) / 100.0)
            pos = (pos[0], pos[1] + bar_height + 4)

            pos = font.text(draw, (left, pos[1]),
                            'Write', 'small')
            widgets.horizontal_bar(draw, left, pos[1],
                                   self.width - left, pos[1] + bar_height,
                                   float(write) / 100.0)

            self.image = image
            self.new_image_is_ready()
            measurement_time = 2
Example #3
0
    def get_cpu_load_and_redraw(self):
        bar_height = self.height - widgets.title_height - bottom_margin - 3
        width_cpu = self.width / nof_cpu
        bar_width = 0.5 * width_cpu
        bar_margin = (width_cpu - bar_width) / 2
        interval = 0.05

        while not self.is_terminated():
            image, draw = self.get_new_image_and_canvas()

            font.text(draw, (self.width / 2, widgets.title_height / 2),
                      'CpuLoad', alignment='middle')

            ret = subprocess.check_output(
                'LANG=C top -d%f -bn2 | grep "Cpu[0123]" | tail -n%d | '
                'awk \'{print $3}\' | cut -d/ -f1' %
                (interval, nof_cpu), shell=True)

            percentages = [float(x) for x in ret.split()]
            interval = 0.5
            x = bar_margin

            for cpu in percentages:
                y2 = self.height - bottom_margin
                widgets.vertical_bar(draw,
                                     x, y2 - bar_height - 1,
                                     x + bar_width, y2, cpu / 100.0)
                x += width_cpu

            self.image = image
            del image
            del draw
            self.new_image_is_ready()
Example #4
0
    def get_cpu_load_and_redraw(self):
        xc = self.width / 2
        yh = self.height - widgets.title_height
        yc = widgets.title_height + yh / 2
        r = self.height - bottom_margin - yc

        while not self.is_terminated():
            image, draw = self.get_new_image_and_canvas()

            font.text(draw, (self.width / 2, widgets.title_height / 2),
                      'CpuTemp', alignment='middle')

            try:
                ret = subprocess.check_output(
                    ['/opt/vc/bin/vcgencmd measure_temp'], shell=True)
                temperature = float(re.search("\d+\.\d+",
                                    ret.decode('utf8')).group(0))
                widgets.meter(draw, xc - r, yc - r, xc + r, yc + r,
                              40, 80, temperature)
            except:
                font.text(draw, (xc, yc), 'not pi ?', alignment='middle')

            self.image = image
            del image
            del draw
            self.new_image_is_ready()
            time.sleep(2)
 def show(Text, screen, i, j):
     for event in pygame.event.get():
         if event.type == pygame.QUIT:
             exit(0)
     clock.tick(60)
     Blit.row_draw(blits, i, j)
     text(Text, screen).display()
     pygame.display.flip()
     screen.fill(WHITE)
class bruiser_battleaxe:
    '''
   . /\ .
 //`-||-'\\
(| -=||=- |)
 \\,-||-.//
   ' || '
     ||
     ||
     ||
     ||
     ||
     ()

  '''
    def graphic():
        print("   , /\ ,     ")
        print(" //'-||-'\\\   ")
        print('(| -=||=- |)  ')
        print(' \\\.-||-.//   ')
        print("   ` || `     ")
        print('     ||       ')
        print('     ||       ')
        print('     ||       ')
        print('     ||       ')
        print('     ||       ')
        print('     ()       ')

    item_rarity = rarity.green
    name = font.text(item_rarity, 'Bruiser Battleaxe')
    poisoning = False

    stats = {'Damage': 3, 'Accuracy': 0.8}
Example #7
0
    def drawrow(self, c, y0, i0, n, space, rh):
        x = 0
        #b1 = (x, y0 - rh)

        for i in range(i0, i0 + n):
            d = self.devices[i]
            p = self.padding[i]
            v1, v2 = d.get_bounding_box()
            w, h = v2 - v1

            # add device
            vspace = (rh - self.texth - h - p[1] - p[3]) / 2.
            origin = (x + p[0] - v1[0], y0 - vspace - p[1] - v2[1])
            c.add(CellReference(d, origin=origin))

            # add device id
            if self.texth > 0:
                text = font.text("%04d" % i, self.texth)
                t1, t2 = text.get_bounding_box()
                tw, th = t2 - t1
                origin = (x + (p[0] + w + p[2] - tw) / 2.,
                          y0 - rh - t1[1] + (self.texth - th) / 2.)
                c.add(CellReference(text, origin=origin))
            x += p[0] + w + p[2] + space

        # add LightField Area Box over devices
        b1 = (0, y0 - rh + self.texth)
        b2 = (x - space, y0)
        c.add(Rectangle(b1, b2, layer=WGLFAREA))

        # add NO_FILL box over text
        if self.texth > 0:
            b1 = (0, y0 - rh)
            b2 = (x - space, b1[1] + self.texth)
            c.add(Rectangle(b1, b2, layer=NO_FILL))
 def sort(self):
     self.name = "INSERTION SORT"
     self.Text = text(self.name, self.screen)
     for i in range(1, blen):
         temp = self.arr[i]
         pos = i - 1
         while pos != 0 and temp.H() < self.arr[pos].H():
             self.arr[pos + 1] = self.arr[pos]
             pos -= 1
         self.arr[pos] = temp
         Sort.show(self.name, self.screen, pos, i)
Example #9
0
    def get_clock(self):
        x = self.width / 2
        last_secs = 0
        ymd_divisors = [
            60 * 60 * 24 * 30 * 12, 60 * 60 * 24 * 30, 60 * 60 * 24
        ]
        hms_divisors = [60 * 60, 60, 1]

        while not self.is_terminated():
            if int(time.time()) != last_secs:
                last_secs = int(time.time())

                now = time.strftime('%H:%M:%S', time.gmtime())

                with open('/proc/uptime', 'r') as f:
                    uptime = int(f.readline().split(".")[0])

                ymd = ''
                for d in ymd_divisors:
                    f = int(uptime / d)
                    uptime -= d * f
                    ymd += '%02d:' % f
                ymd = ymd[:-1]

                hms = ''
                for d in hms_divisors:
                    f = int(uptime / d)
                    uptime -= d * f
                    hms += '%02d:' % f
                hms = hms[:-1]

                image, draw = self.get_new_image_and_canvas()
                pos = font.text(draw, (x, 3), now, 'large', 'hcenter')
                pos = font.text(draw, (x, pos[1]), 'UPTIME', 'small',
                                'hcenter')
                pos = font.text(draw, (x, pos[1]), ymd, 'normal', 'hcenter')
                pos = font.text(draw, (x, pos[1]), hms, 'normal', 'hcenter')
                self.image = image
                self.new_image_is_ready()

            time.sleep(1)
class goblin_shiv:
    '''
             />
            /<
  O[/\//\\:(O)>===========================-
            \<
             \>
  '''
    def graphic():
        print(font.rarity_green('      />'))
        print(font.rarity_green('O[///(>================-'))
        print(font.rarity_green('      \>'))

    item_rarity = rarity.green
    name = font.text(item_rarity, 'Goblin Shiv')
    poisoning = True

    stats = {
        'Damage': 1,
        'Accuracy': 1.0,
        'Effect': font.text(rarity.grey, 'Poison I')
    }
Example #11
0
    def get_clock(self):
        x = self.width / 2
        left = 5

        while not self.is_terminated():
            ret = subprocess.check_output(
                'df -h | grep " /$" | awk \'{print $3 " " $4}\'', shell=True)
            used, free = ret.decode('utf-8').split()
            image, draw = self.get_new_image_and_canvas()
            pos = font.text(draw, (x, 3),
                            'Disk', 'large', 'hcenter')
            pos = font.text(draw, (left, pos[1]),
                            'Used:', 'small')
            pos = font.text(draw, (self.width - 5, pos[1] - 3),
                            used, 'normal', 'right')
            pos = font.text(draw, (left, pos[1] - 5),
                            'Free:', 'small')
            pos = font.text(draw, (self.width - 5, pos[1] - 3),
                            free, 'normal', 'right')
            self.image = image
            self.new_image_is_ready()
            time.sleep(1)
Example #12
0
    def get_clock(self):
        x = self.width / 2
        left = 5

        while not self.is_terminated():
            ret = subprocess.check_output(
                'free -h | xargs | awk \'{print $13 " " $16}\'', shell=True)
            mem_free, swap_used = ret.split()

            image, draw = self.get_new_image_and_canvas()
            pos = font.text(draw, (x, 3),
                            'Memory', 'large', 'hcenter')
            pos = font.text(draw, (left, pos[1]),
                            'Free:', 'small')
            pos = font.text(draw, (self.width - 5, pos[1] - 3),
                            mem_free.decode('utf-8'), 'normal', 'right')
            pos = font.text(draw, (left, pos[1] - 3),
                            'Swapped:', 'small')
            pos = font.text(draw, (self.width - 5, pos[1] - 3),
                            swap_used.decode('utf-8'), 'normal', 'right')
            self.image = image
            self.new_image_is_ready()
            time.sleep(1.8)
class wooden_sword:
    '''
        /| ________________
  O|===|* >_______________/
        \|                  
  '''
    def graphic():
        print('      /| ________________')
        print('O|===|* >_______________/')
        print('      \|')

    item_rarity = rarity.grey
    name = font.text(item_rarity, 'Wooden Sword')
    poisoning = False

    stats = {'Damage': 1, 'Accuracy': 1.0}
Example #14
0
def meter(draw, x1, y1, x2, y2, min, max, value):
    rx = (x2 - x1) / 2
    ry = (y2 - y1) / 2
    xc = x1 + rx
    yc = y1 + ry
    draw.ellipse([x1, y1, x2, y2], 'black', 'white')
    draw.ellipse([xc - 2, yc - 2, xc + 2, yc + 2], 'white', 'white')

    def point(val, offset=0):
        deflection = float(val - min) / (max - min)
        rad = (math.pi * 3) / 4 + (math.pi * deflection * 6) / 4
        return (xc + math.cos(rad) * (rx + offset),
                yc + math.sin(rad) * (ry + offset))

    x, y = point(min)
    x -= 12
    font.text(draw, (x, y), str(min), 'small')

    x, y = point(max)
    x += 5
    font.text(draw, (x, y), str(max), 'small')

    range = max - min
    second = int(min + range / 3)
    third = int(min + 2 * range / 3)

    x, y = point(second)
    x -= 12
    font.text(draw, (x, y), str(second), 'small', alignment='low')

    x, y = point(third)
    x += 5
    font.text(draw, (x, y), str(third), 'small', alignment='low')

    if value > max:
        value = max + range / 50
    elif value < min:
        value = min - range / 50
    draw.line([xc, yc, point(value, -4)], 'white')
class none:

    item_rarity = rarity.grey
    name = font.text(item_rarity, 'None')
    poisoning = False
class goblin_head:
    rarity = rarity.green
    name = font.text(rarity, 'Goblin Head')