-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from tallero/win32
Add Windows support
- Loading branch information
Showing
6 changed files
with
128 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Config | ||
# | ||
# ---------------------------------------------------------------------- | ||
# Copyright © 2018, 2019, 2020, 2021 Pellegrino Prevete | ||
# | ||
# All rights reserved | ||
# ---------------------------------------------------------------------- | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
from appdirs import user_cache_dir, user_config_dir, user_data_dir | ||
from logging import basicConfig as set_log_config | ||
from logging import INFO as log_level_info | ||
from os.path import join as path_join | ||
from os import makedirs, umask | ||
|
||
|
||
def mkdirs(newdir, mode=0o700): | ||
"""Because no -p in os.mkdir""" | ||
original_umask = umask(0) | ||
try: | ||
makedirs(newdir, mode) | ||
except OSError: | ||
pass | ||
finally: | ||
umask(original_umask) | ||
|
||
|
||
class Config: | ||
appname = "pgpgram" | ||
appauthor = "Pellegrino Prevete" | ||
|
||
def __init__(self, | ||
log_level=log_level_info): | ||
self.setup_logging(log_level) | ||
self.setup_dirs() | ||
|
||
def get_db_path(self, db_name: str) -> str: | ||
return path_join(self.get_data_dir(), ".".join([db_name, 'db'])) | ||
|
||
def get_cache_dir(self) -> str: | ||
return user_cache_dir(self.appname, self.appauthor) | ||
|
||
def get_config_dir(self) -> str: | ||
return user_config_dir(self.appname, self.appauthor) | ||
|
||
def get_data_dir(self) -> str: | ||
return user_data_dir(self.appname, self.appauthor) | ||
|
||
def setup_dirs(self) -> None: | ||
mkdirs(self.get_cache_dir()) | ||
mkdirs(self.get_config_dir()) | ||
mkdirs(self.get_data_dir()) | ||
|
||
def setup_logging(self, level: int) -> None: | ||
"""Set verbose level""" | ||
log_config_args = { | ||
'format': '%(asctime)s %(levelname)-8s %(message)s', | ||
'level': level, | ||
'datefmt': '%Y-%m-%d %H:%M:%S' | ||
} | ||
set_log_config(**log_config_args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,33 @@ | ||
"""Setup for PGPgram""" | ||
from platform import system, machine | ||
from setuptools import setup, find_packages | ||
|
||
with open("README.md", "r") as fh: | ||
long_description = fh.read() | ||
|
||
setup( | ||
name = "PGPgram", | ||
version = "0.3.1", | ||
author = "Pellegrino Prevete", | ||
author_email = "[email protected]", | ||
description = "GPG encrypted backups on telegram", | ||
long_description = long_description, | ||
long_description_content_type = "text/markdown", | ||
url = "https://github.com/tallero/PGPgram", | ||
packages = find_packages(), | ||
package_data = { | ||
'': ['libtdjson.so'], | ||
name="PGPgram", | ||
version="0.4", | ||
author="Pellegrino Prevete", | ||
author_email="[email protected]", | ||
description="GPG encrypted backups on telegram", | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
url="https://github.com/tallero/PGPgram", | ||
packages=find_packages(), | ||
package_data={ | ||
'': ['libtdjson_{}_{}.so'.format(system(), machine())], | ||
}, | ||
entry_points = { | ||
entry_points={ | ||
'console_scripts': ['pgpgram = pgpgram:main'] | ||
}, | ||
install_requires = [ | ||
'pyxdg', | ||
'setproctitle', | ||
'sqlitedict', | ||
'trovotutto', | ||
install_requires=[ | ||
'appdirs', | ||
'setproctitle', | ||
'sqlitedict', | ||
'trovotutto', | ||
], | ||
classifiers = [ | ||
classifiers=[ | ||
"Programming Language :: Python :: 3", | ||
"License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)", | ||
"Operating System :: Unix", | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.