def main(): load_settings_from_cloud() # load image file list file_list = [] for file in os.listdir(IMG_DIR): # get (png|jpg|jpeg|gif) files. and skip dot files. if re.search('^[^\.].*\.(png|jpg|jpeg|gif)', file, re.IGNORECASE): file_list.append(file) if len(file_list) == 0: print('no image, exit.') sys.exit(0) file_list.sort() print(file_list) nafuda = Nafuda() data = local_settings() while True: for file in file_list: # QRコード置換用画像が来た if file == CLOUD_QR_CODE_FILE_NAME: # CLOUD_BASE_URLがなければ、QRコードを表示しない if "CLOUD_BASE_URL" in data and data['CLOUD_BASE_URL'] != "": # QRコードを合成して表示 base_image = Image.open(CLOUD_QR_CODE_FILE_PATH) qr_img = get_control_url_qrcode_img() base_image.paste(qr_img, (10, 10)) nafuda.draw_image_buffer(base_image, orientation=90) if "PSEUDO_EPD_MODE" in os.environ: # guard for img bomb. time.sleep(3) continue try: nafuda.draw_image_file(IMG_DIR + '/' + file, 90) except OSError: # maybe, the file is not correct image file. print("load image fail: " + file) if "PSEUDO_EPD_MODE" in os.environ: # guard for img bomb. time.sleep(3) # 一枚しか画像がなければ、スライドショーする意味がないので終了 if len(file_list) == 1: exit(0)
def main(): if len(sys.argv) != 2: show_help() sys.exit() if sys.argv[1] == '-h' or sys.argv[1] == '--help': show_help() sys.exit() file_path = sys.argv[1] if not os.path.isfile(file_path): print('file not found :' + file_path) sys.exit() nafuda = Nafuda() # Orientation 90 is vertical nafuda mode. 0 is horizontal nafuda.draw_image_file(file_path, orientation=90)