comparison sat/core/constants.py @ 3480:7550ae9cfbac

Renamed the project from "Salut à Toi" to "Libervia": This renaming follows the decision taken at the General Assemblee of January 27th 2021 (cf. https://repos.goffi.org/sat_docs/raw-file/tip/association/2021-01-27%20-%20compte%20rendu%20de%20l%27AG%20extraordinaire.pdf)
author Goffi <goffi@goffi.org>
date Sat, 20 Mar 2021 20:42:04 +0100
parents be6d91572633
children 509f7a1c67dc
comparison
equal deleted inserted replaced
3479:be6d91572633 3480:7550ae9cfbac
1 #!/usr/bin/env python3 1 #!/usr/bin/env python3
2 2
3 3 # Libervia: an XMPP client
4 # SàT: a XMPP client
5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org) 4 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
6 5
7 # This program is free software: you can redistribute it and/or modify 6 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as published by 7 # it under the terms of the GNU Affero General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or 8 # the Free Software Foundation, either version 3 of the License, or
27 26
28 27
29 class Const(object): 28 class Const(object):
30 29
31 ## Application ## 30 ## Application ##
32 APP_NAME = "Salut à Toi" 31 APP_NAME = "Libervia"
33 APP_NAME_SHORT = "SàT" 32 APP_COMPONENT = "backend"
34 APP_NAME_FILE = "sat" 33 APP_NAME_ALT = "SàT"
35 APP_NAME_FULL = "{name_short} ({name})".format( 34 APP_NAME_FILE = "libervia"
36 name_short=APP_NAME_SHORT, name=APP_NAME 35 APP_NAME_FULL = f"{APP_NAME} ({APP_COMPONENT})"
37 )
38 APP_VERSION = ( 36 APP_VERSION = (
39 sat.__version__ 37 sat.__version__
40 ) # Please add 'D' at the end of version in sat/VERSION for dev versions 38 ) # Please add 'D' at the end of version in sat/VERSION for dev versions
41 APP_RELEASE_NAME = "La Cecília" 39 APP_RELEASE_NAME = "La Cecília"
42 APP_URL = "https://salut-a-toi.org" 40 APP_URL = "https://salut-a-toi.org"
438 436
439 ## Configuration ## 437 ## Configuration ##
440 if ( 438 if (
441 BaseDirectory 439 BaseDirectory
442 ): # skipped when xdg module is not available (should not happen in backend) 440 ): # skipped when xdg module is not available (should not happen in backend)
443 if "org.salutatoi.cagou" in BaseDirectory.__file__: 441 if "org.libervia.cagou" in BaseDirectory.__file__:
444 # FIXME: hack to make config read from the right location on Android 442 # FIXME: hack to make config read from the right location on Android
445 # TODO: fix it in a more proper way 443 # TODO: fix it in a more proper way
446 444
447 # we need to use Android API to get downloads directory 445 # we need to use Android API to get downloads directory
448 import os.path 446 import os.path
455 453
456 Environment = autoclass("android.os.Environment") 454 Environment = autoclass("android.os.Environment")
457 455
458 BaseDirectory = None 456 BaseDirectory = None
459 Const.DEFAULT_CONFIG = { 457 Const.DEFAULT_CONFIG = {
460 "local_dir": "/data/data/org.salutatoi.cagou/app", 458 "local_dir": "/data/data/org.libervia.cagou/app",
461 "media_dir": "/data/data/org.salutatoi.cagou/files/app/media", 459 "media_dir": "/data/data/org.libervia.cagou/files/app/media",
462 # FIXME: temporary location for downloads, need to call API properly 460 # FIXME: temporary location for downloads, need to call API properly
463 "downloads_dir": os.path.join( 461 "downloads_dir": os.path.join(
464 Environment.getExternalStoragePublicDirectory( 462 Environment.getExternalStoragePublicDirectory(
465 Environment.DIRECTORY_DOWNLOADS 463 Environment.DIRECTORY_DOWNLOADS
466 ).getAbsolutePath(), 464 ).getAbsolutePath(),
468 ), 466 ),
469 "pid_dir": "%(local_dir)s", 467 "pid_dir": "%(local_dir)s",
470 "log_dir": "%(local_dir)s", 468 "log_dir": "%(local_dir)s",
471 } 469 }
472 Const.CONFIG_FILES = [ 470 Const.CONFIG_FILES = [
473 "/data/data/org.salutatoi.cagou/files/app/android/" 471 "/data/data/org.libervia.cagou/files/app/android/"
474 + Const.APP_NAME_FILE 472 + Const.APP_NAME_FILE
475 + ".conf" 473 + ".conf"
476 ] 474 ]
477 else: 475 else:
478 import os 476 import os
483 # /etc/_sat.conf is used for system-related settings (e.g. when media_dir 481 # /etc/_sat.conf is used for system-related settings (e.g. when media_dir
484 # is set by the distribution and has not reason to change, or in a Docker 482 # is set by the distribution and has not reason to change, or in a Docker
485 # image) 483 # image)
486 ["/etc/_", "/etc/", "~/", "~/."] 484 ["/etc/_", "/etc/", "~/", "~/."]
487 + [ 485 + [
488 "%s/" % path 486 "{}/".format(path)
489 for path in list(BaseDirectory.load_config_paths(Const.APP_NAME_FILE)) 487 for path in list(BaseDirectory.load_config_paths(Const.APP_NAME_FILE))
488 ]
489 # this is to handle legacy sat.conf
490 + [
491 "{}/".format(path)
492 for path in list(BaseDirectory.load_config_paths("sat"))
490 ] 493 ]
491 + [root_dir] 494 + [root_dir]
492 ) 495 )
493 496
494 # on recent versions of Flatpak, FLATPAK_ID is set at run time 497 # on recent versions of Flatpak, FLATPAK_ID is set at run time
510 513
511 # List of the configuration filenames sorted by ascending priority 514 # List of the configuration filenames sorted by ascending priority
512 Const.CONFIG_FILES = [ 515 Const.CONFIG_FILES = [
513 realpath(expanduser(path) + Const.APP_NAME_FILE + ".conf") 516 realpath(expanduser(path) + Const.APP_NAME_FILE + ".conf")
514 for path in Const.CONFIG_PATHS 517 for path in Const.CONFIG_PATHS
518 ] + [
519 # legacy sat.conf
520 realpath(expanduser(path) + "sat.conf")
521 for path in Const.CONFIG_PATHS
515 ] 522 ]
516 523