comparison libervia/backend/core/constants.py @ 4270:0d7bb4df2343

Reformatted code base using black.
author Goffi <goffi@goffi.org>
date Wed, 19 Jun 2024 18:44:57 +0200
parents 9fc3d28bc3f6
children
comparison
equal deleted inserted replaced
4269:64a85ce8be70 4270:0d7bb4df2343
44 APP_NAME = "Libervia" 44 APP_NAME = "Libervia"
45 APP_COMPONENT = "backend" 45 APP_COMPONENT = "backend"
46 APP_NAME_ALT = "Libervia" 46 APP_NAME_ALT = "Libervia"
47 APP_NAME_FILE = "libervia" 47 APP_NAME_FILE = "libervia"
48 APP_NAME_FULL = f"{APP_NAME} ({APP_COMPONENT})" 48 APP_NAME_FULL = f"{APP_NAME} ({APP_COMPONENT})"
49 APP_VERSION = ( 49 APP_VERSION = backend.__version__
50 backend.__version__
51 )
52 APP_RELEASE_NAME = "La Ruche" 50 APP_RELEASE_NAME = "La Ruche"
53 APP_URL = "https://libervia.org" 51 APP_URL = "https://libervia.org"
54 52
55 ## Runtime ## 53 ## Runtime ##
56 PLUGIN_EXT = "py" 54 PLUGIN_EXT = "py"
115 ENTITY_TYPE_MUC = "MUC" 113 ENTITY_TYPE_MUC = "MUC"
116 114
117 ## Roster jids selection ## 115 ## Roster jids selection ##
118 PUBLIC = "PUBLIC" 116 PUBLIC = "PUBLIC"
119 ALL = ( 117 ALL = (
120 "ALL" 118 "ALL" # ALL means all known contacts, while PUBLIC means everybody, known or not
121 ) # ALL means all known contacts, while PUBLIC means everybody, known or not 119 )
122 GROUP = "GROUP" 120 GROUP = "GROUP"
123 JID = "JID" 121 JID = "JID"
124 122
125 ## Messages ## 123 ## Messages ##
126 MESS_TYPE_INFO = "info" 124 MESS_TYPE_INFO = "info"
224 # to make the header more readable 222 # to make the header more readable
225 PI_NAME = "name" 223 PI_NAME = "name"
226 PI_IMPORT_NAME = "import_name" 224 PI_IMPORT_NAME = "import_name"
227 PI_MAIN = "main" 225 PI_MAIN = "main"
228 PI_HANDLER = "handler" 226 PI_HANDLER = "handler"
229 PI_TYPE = ( 227 PI_TYPE = "type" #  FIXME: should be types, and should handle single unicode type or tuple of types (e.g. "blog" and "import")
230 "type"
231 ) #  FIXME: should be types, and should handle single unicode type or tuple of types (e.g. "blog" and "import")
232 PI_MODES = "modes" 228 PI_MODES = "modes"
233 PI_PROTOCOLS = "protocols" 229 PI_PROTOCOLS = "protocols"
234 PI_DEPENDENCIES = "dependencies" 230 PI_DEPENDENCIES = "dependencies"
235 PI_RECOMMENDATIONS = "recommendations" 231 PI_RECOMMENDATIONS = "recommendations"
236 PI_DESCRIPTION = "description" 232 PI_DESCRIPTION = "description"
403 KEY_ATTACHMENTS = "attachments" 399 KEY_ATTACHMENTS = "attachments"
404 KEY_ATTACHMENTS_MEDIA_TYPE = "media_type" 400 KEY_ATTACHMENTS_MEDIA_TYPE = "media_type"
405 KEY_ATTACHMENTS_PREVIEW = "preview" 401 KEY_ATTACHMENTS_PREVIEW = "preview"
406 KEY_ATTACHMENTS_RESIZE = "resize" 402 KEY_ATTACHMENTS_RESIZE = "resize"
407 403
408
409 ## Common extra keys/values ## 404 ## Common extra keys/values ##
410 KEY_ORDER_BY = "order_by" 405 KEY_ORDER_BY = "order_by"
411 KEY_USE_CACHE = "use_cache" 406 KEY_USE_CACHE = "use_cache"
412 KEY_DECRYPT = "decrypt" 407 KEY_DECRYPT = "decrypt"
413 408
414 ORDER_BY_CREATION = 'creation' 409 ORDER_BY_CREATION = "creation"
415 ORDER_BY_MODIFICATION = 'modification' 410 ORDER_BY_MODIFICATION = "modification"
416 411
417 # internationalisation 412 # internationalisation
418 DEFAULT_LOCALE = "en_GB" 413 DEFAULT_LOCALE = "en_GB"
419 414
420 ## Command Line ## 415 ## Command Line ##
430 EXIT_DATA_ERROR = 17 # data needed for a command is invalid 425 EXIT_DATA_ERROR = 17 # data needed for a command is invalid
431 EXIT_MISSING_FEATURE = 18 # a needed plugin or feature is not available 426 EXIT_MISSING_FEATURE = 18 # a needed plugin or feature is not available
432 EXIT_CONFLICT = 19 # an item already exists 427 EXIT_CONFLICT = 19 # an item already exists
433 EXIT_USER_CANCELLED = 20 # user cancelled action 428 EXIT_USER_CANCELLED = 20 # user cancelled action
434 EXIT_INTERNAL_ERROR = 111 # unexpected error 429 EXIT_INTERNAL_ERROR = 111 # unexpected error
435 EXIT_FILE_NOT_EXE = ( 430 EXIT_FILE_NOT_EXE = 126 # a file to be executed was found, but it was not an executable utility (cf. man 1 exit)
436 126
437 ) # a file to be executed was found, but it was not an executable utility (cf. man 1 exit)
438 EXIT_CMD_NOT_FOUND = 127 # a utility to be executed was not found (cf. man 1 exit) 431 EXIT_CMD_NOT_FOUND = 127 # a utility to be executed was not found (cf. man 1 exit)
439 EXIT_CMD_ERROR = 127 # a utility to be executed returned an error exit code 432 EXIT_CMD_ERROR = 127 # a utility to be executed returned an error exit code
440 EXIT_SIGNAL_INT = 128 # a command was interrupted by a signal (cf. man 1 exit) 433 EXIT_SIGNAL_INT = 128 # a command was interrupted by a signal (cf. man 1 exit)
441 434
442 ## Misc ## 435 ## Misc ##
490 import os.path 483 import os.path
491 from jnius import autoclass 484 from jnius import autoclass
492 485
493 # we don't want the very verbose jnius log when we are in DEBUG level 486 # we don't want the very verbose jnius log when we are in DEBUG level
494 import logging 487 import logging
495 logging.getLogger('jnius').setLevel(logging.WARNING) 488
496 logging.getLogger('jnius.reflect').setLevel(logging.WARNING) 489 logging.getLogger("jnius").setLevel(logging.WARNING)
490 logging.getLogger("jnius.reflect").setLevel(logging.WARNING)
497 491
498 Environment = autoclass("android.os.Environment") 492 Environment = autoclass("android.os.Environment")
499 493
500 BaseDirectory = None 494 BaseDirectory = None
501 Const.DEFAULT_CONFIG = { 495 Const.DEFAULT_CONFIG = {
516 + Const.APP_NAME_FILE 510 + Const.APP_NAME_FILE
517 + ".conf" 511 + ".conf"
518 ] 512 ]
519 else: 513 else:
520 import os 514 import os
515
521 # we use parent of "sat" module dir as last config path, this is useful for 516 # we use parent of "sat" module dir as last config path, this is useful for
522 # per instance configurations (e.g. a dev instance and a main instance) 517 # per instance configurations (e.g. a dev instance and a main instance)
523 root_dir = dirname(dirname(backend.__file__)) + '/' 518 root_dir = dirname(dirname(backend.__file__)) + "/"
524 Const.CONFIG_PATHS = ( 519 Const.CONFIG_PATHS = (
525 # /etc/_sat.conf is used for system-related settings (e.g. when media_dir 520 # /etc/_sat.conf is used for system-related settings (e.g. when media_dir
526 # is set by the distribution and has not reason to change, or in a Docker 521 # is set by the distribution and has not reason to change, or in a Docker
527 # image) 522 # image)
528 ["/etc/_", "/etc/", "~/", "~/."] 523 ["/etc/_", "/etc/", "~/", "~/."]
539 ) 534 )
540 535
541 # on recent versions of Flatpak, FLATPAK_ID is set at run time 536 # on recent versions of Flatpak, FLATPAK_ID is set at run time
542 # it seems that this is not the case on older versions, 537 # it seems that this is not the case on older versions,
543 # but FLATPAK_SANDBOX_DIR seems set then 538 # but FLATPAK_SANDBOX_DIR seems set then
544 if os.getenv('FLATPAK_ID') or os.getenv('FLATPAK_SANDBOX_DIR'): 539 if os.getenv("FLATPAK_ID") or os.getenv("FLATPAK_SANDBOX_DIR"):
545 # for Flatpak, the conf can't be set in /etc or $HOME, so we have 540 # for Flatpak, the conf can't be set in /etc or $HOME, so we have
546 # to add /app 541 # to add /app
547 Const.CONFIG_PATHS.append('/app/') 542 Const.CONFIG_PATHS.append("/app/")
548 543
549 ## Configuration ## 544 ## Configuration ##
550 Const.DEFAULT_CONFIG = { 545 Const.DEFAULT_CONFIG = {
551 "media_dir": "/usr/share/" + Const.APP_NAME_FILE + "/media", 546 "media_dir": "/usr/share/" + Const.APP_NAME_FILE + "/media",
552 "local_dir": BaseDirectory.save_data_path(Const.APP_NAME_FILE), 547 "local_dir": BaseDirectory.save_data_path(Const.APP_NAME_FILE),
562 ] + [ 557 ] + [
563 # legacy sat.conf 558 # legacy sat.conf
564 realpath(expanduser(path) + "sat.conf") 559 realpath(expanduser(path) + "sat.conf")
565 for path in Const.CONFIG_PATHS 560 for path in Const.CONFIG_PATHS
566 ] 561 ]
567