Exemple #1
0
def init(SCREEN=0):
  global i2c, addrs, led, cy
  i2c = machine.I2C(-1, machine.Pin(cfg.SDA_PIN), machine.Pin(cfg.SDL_PIN))

  addrs = i2c.scan()

  if not len(addrs):
    return
    
  led = ssd1306.SSD1306_I2C(m_x, m_y, i2c, addrs[SCREEN])

  clear(1)
  led.invert(1)
  utime.sleep_ms(100)
  clear(0)

  now = date()
  oprint('%s %s' % ( cfg.package, cfg.version ))
  oprint('Host: %s' % ( cfg.hostname ), 0, CH)
  oprint('Date: %s' %  now[:10], 0, CH*2)
  oprint('%s'       % now[12:], 2, CH*3)
  oprint('Uptime: %s' % uptime(), 0, CH*4)

  cy = CH * 5

  led.invert(0)
Exemple #2
0
    def show(self):
        img = Image.new('1', (epd2in7.EPD_WIDTH, epd2in7.EPD_HEIGHT),
                        255)  # 255: clear the frame
        draw = ImageDraw.Draw(img)
        font12 = ImageFont.truetype(
            '/usr/share/fonts/truetype/freefont/FreeSans.ttf', 12)

        Y0 = 60
        line_height = 12
        margin = 5
        for k in range(len(self.lines)):
            draw.text((margin, Y0 + k * line_height),
                      self.lines[k],
                      font=font12,
                      fill=0)

        bigY = epd2in7.EPD_HEIGHT - 46
        draw.line((0, bigY, epd2in7.EPD_WIDTH, bigY), fill=0)
        draw.text((10, bigY + 5), util.date(), font=font12, fill=0)
        draw.text((10, bigY + 17),
                  'connecté au réseau ' + util.get_essid(),
                  font=font12,
                  fill=0)
        draw.text((10, bigY + 29),
                  'adresse IP : ' + util.get_ip_address(),
                  font=font12,
                  fill=0)
        bmp = Image.open('/home/pi/Miniban/src/lib/display/explorer-logo.bmp')
        img.paste(bmp, (0, 0))
        self.epd.display(self.epd.getbuffer(img))
        self.clear()
Exemple #3
0
def welcome():
    pre = '|\t  '
    print('\n' * 2)
    print(' ', end='')
    print('.-v-' * 19)
    print('/' + pre)
    print('\\' + pre, end='')
    print('Welcome to %s %s @ %s.%s' %
          (cfg.package, cfg.version, cfg.hostname, cfg.domainname))
    print('/' + pre)
    print('\\' + pre)
    print('{' + pre, end='')
    print('MicroPython %s (Python %s) on the %s platform' % \
      ('.'.join(map(str,sys.implementation.version)), sys.version, sys.platform))
    print('/' + pre, end='')
    print('    (%s)' % uos.uname().version)
    print('\\' + pre)
    print('/' + pre, end='')
    try:
        print('Local time is %s, enjoy.' % date())
    except:
        pass
    print('\\' + pre)
    print('/' + pre, end='')
    print(' ' * 53, '~~`')
    print('\\' + pre)
    print('/' + pre, end='')
    print('   ... there is but only one way to death - through life.')
    print('\\' + pre)
    print('+', ',..,,' * 15)
    print('')
    print('')
    print('Loaded modules: %s' % ', '.join(sorted(list(sys.modules.keys()))))
Exemple #4
0
 def __summarize(self) -> str:
     self.data_handler.update()
     data = self.data_handler.newest_data_line
     update_info = self.data_handler.update_info
     out: str = strings['descriptor-date'].format(
         util.date(update_info["vaccinationsLastUpdated"]))
     for summarize_id, desc, convert in summarize_ids:
         out += desc.format(convert(data[summarize_id]))
     return out
Exemple #5
0
def cmdtime(topic, msg):
    from cfg import ESPConfig
    cfg = ESPConfig()

    from util import date
    from utime import mktime
    from ure import compile, match
    src = topic[1]
    try:
        newdate = msg[0:-6]
        assert compile(r"^[0-9,'() ]+$").match(newdate)

        newdate = eval(newdate)
        tz = msg[-5:]
        newdate = mktime(newdate)
    except Exception as e:
        print('Incorrect time msg from %s: "%s" -- %s' % (src, msg, e))
        return

    print("Net date: %s Our date: %s" % (date(newdate), date()))

    if src in cfg.timelords:
        # check timezones...
        if (newdate < time()) and (time() - newdate > cfg.MAX_TS_DRIFT):
            print('%s has incorrect time by %s seconds!' % (time() - newdate))
            return
        elif time() < newdate and (newdate - time() > cfg.MAX_TS_DRIFT):
            print('Clock is off by more than a minute, updating time')

            cfg.timezone = tz
            from machine import RTC
            print('OLD: %s' % date())
            RTC.datetime((now))
            print('NEW: %s' % date())
            del RTC
    else:
        print("Net date: %s Our date: %s" % (date(newdate), date()))

    del mktime, compile, match
Exemple #6
0
 NODE_KEY = "a88b92531ba974f68bc1fd5938fc77"
 NODE_DEBUG = 0
 SERVER = "http://w/uauc/playweb/"
 util.msg("PlayWeb Node 1.0")
 util.msg("Server:%s Key:%s Debug:%d" % (SERVER, NODE_KEY, NODE_DEBUG))
 util.msg("Listening server project...")
 while 1:
     r = util.http_get(SERVER + "/index.php?m=node&a=get_task")
     if r['data'] != " ":
         O = eval(util.decode_str(r['data'], NODE_KEY))
         break
     time.sleep(1)
 O['debug'] = NODE_DEBUG
 util.msg(
     "[Project] Target:%s  Time:%s Module:%s  Thread:%s" %
     (O['target'], util.date(O['start_time']), O['module'], O['thread']), 1)
 O['target'] = "w"
 O['key'] = NODE_KEY
 #O['depth'] = 5  # notice
 O['server_url'] = SERVER + "?m=node&a="
 O['web-ports'] = util.csv2array(O['web-ports'])
 O['app-ports'] = util.csv2array(O['app-ports'])
 O['file-ext'] = util.csv2array(O['file-ext'])
 O['module'] = util.csv2array(O['module'])
 g.config(O)
 # print g.O
 info = scanner()
 urls = []
 if info['web']:
     target = Url("http://" + O['target'])
     crawler = Crawler(target)
def publication_date(doi):
    return util.date(get(doi)['records'][0]['publicationDate'])
Exemple #8
0
 
    O = {}
    NODE_KEY = "a88b92531ba974f68bc1fd5938fc77"
    NODE_DEBUG = 0
    SERVER = "http://w/uauc/playweb/"
    util.msg("PlayWeb Node 1.0")
    util.msg("Server:%s Key:%s Debug:%d" % (SERVER, NODE_KEY, NODE_DEBUG))
    util.msg("Listening server project...")
    while 1:
        r = util.http_get(SERVER + "/index.php?m=node&a=get_task")
        if r['data'] != " " :
            O = eval(util.decode_str(r['data'], NODE_KEY))
            break
        time.sleep(1)
    O['debug'] = NODE_DEBUG
    util.msg("[Project] Target:%s  Time:%s Module:%s  Thread:%s" % (O['target'], util.date(O['start_time']), O['module'], O['thread']), 1)
    O['target'] = "w"
    O['key'] = NODE_KEY
    #O['depth'] = 5  # notice
    O['server_url'] = SERVER + "?m=node&a="
    O['web-ports'] = util.csv2array(O['web-ports'])
    O['app-ports'] = util.csv2array(O['app-ports'])
    O['file-ext'] = util.csv2array(O['file-ext'])
    O['module'] = util.csv2array(O['module'])
    g.config(O)
    # print g.O
    info = scanner()
    urls = []
    if info['web']:
        target = Url("http://" + O['target'])
        crawler = Crawler(target)
Exemple #9
0
 
    O = {}
    NODE_KEY = "a88b92531ba974f68bc1fd5938fc77"
    NODE_DEBUG = 0
    SERVER = "http://w/uauc/playweb/"
    util.msg("PlayWeb Node 1.0")
    util.msg("Server:%s Key:%s Debug:%d" % (SERVER, NODE_KEY, NODE_DEBUG))
    util.msg("Listening server project...")
    while 1:
        r = util.http_get(SERVER + "/index.php?m=node&a=get_task")
        if r['data'] != " " :
            O = eval(util.decode_str(r['data'], NODE_KEY))
            break
        time.sleep(1)
    O['debug'] = NODE_DEBUG
    util.msg("[Project] Target:%s  Time:%s Module:%s  Thread:%s" % (O['target'], util.date(O['start_time']), O['module'], O['thread']), 1)
    O['target'] = "w"
    O['key'] = NODE_KEY
    #O['depth'] = 5  # notice
    O['server_url'] = SERVER + "?m=node&a="
    O['web-ports'] = util.csv2array(O['web-ports'])
    O['app-ports'] = util.csv2array(O['app-ports'])
    O['file-ext'] = util.csv2array(O['file-ext'])
    O['module'] = util.csv2array(O['module'])
    g.config(O)
    # print g.O
    info = scanner()
    urls = []
    if info['web']:
        target = Url("http://" + O['target'])
        crawler = Crawler(target)