Warning, /graphics/krita/libs/ui/tests/data/AppImageUpdateDummy is written in an unsupported language. File is not indexed.
0001 #!/usr/bin/env python3 0002 0003 import sys 0004 import os 0005 import argparse 0006 import os.path 0007 0008 EXIT_RUNTIME_ERROR = 255 0009 EXIT_OK = 0 0010 EXIT_ERROR = 1 0011 0012 EXIT_CHECK_UPTODATE = 0 0013 EXIT_CHECK_ERROR = 2 0014 EXIT_CHECK_UPDATE_AVAIL = 1 0015 0016 EXIT_INVALID_USAGE = 100 0017 0018 # files that govern the output of this dummy 0019 states = { 0020 "check_uptodate": EXIT_CHECK_UPTODATE, 0021 "check_update_avail": EXIT_CHECK_UPDATE_AVAIL, 0022 "check_error": EXIT_CHECK_ERROR, 0023 "check_updinfo_empty": EXIT_RUNTIME_ERROR, 0024 "update_ok": EXIT_OK, 0025 "update_error": EXIT_ERROR, 0026 "runtime_error": EXIT_RUNTIME_ERROR 0027 } 0028 0029 parser = argparse.ArgumentParser() 0030 parser.add_argument('--check-for-update', dest='check_for_update', action='store_true', 0031 help='only check if updates are available') 0032 parser.add_argument('appimage_path', metavar='APPIMAGE_PATH', type=str, help='path to the appimage') 0033 0034 args = parser.parse_args() 0035 0036 0037 if "APPIMAGEUPDATE_DUMMY_STATE" not in os.environ.keys(): 0038 sys.exit(EXIT_INVALID_USAGE) 0039 0040 state_string = str(os.environ["APPIMAGEUPDATE_DUMMY_STATE"]) 0041 0042 # if we want to test the update, return update available for --check-for-update 0043 if (args.check_for_update): 0044 if state_string in [ 'update_ok', 'update_error', 'runtime_error' ]: 0045 sys.exit(EXIT_CHECK_UPDATE_AVAIL) 0046 0047 # else lookup the state in the dict 0048 if (state_string in states.keys()): 0049 state = states[state_string] 0050 0051 if state_string in ['update_error', 'runtime_error']: 0052 print("DUMMY: an error occurred") 0053 0054 sys.exit(states[state_string]) 0055 0056 else: 0057 sys.exit(EXIT_INVALID_USAGE)