Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: update Python version #325

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ jobs:
matrix:
python:
# Versions 3.0 - 3.5 are not provided by actions/python-versions
- '3.6'
- '3.7'
- '3.8'
- '3.9'
- '3.10'
os: [ubuntu-18.04, windows-latest, macos-latest]
- '3.11'
- '3.12'
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- name: Checkout code
Expand All @@ -44,12 +43,13 @@ jobs:
fetch-depth: 5

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

- name: Minimal setuptools load-test
run: |
python -m pip install setuptools
python setup.py --fullname
python setup.py --description
python setup.py --long-description
Expand Down
16 changes: 10 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,29 @@ on:

jobs:
lint:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
name: Code linting

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python 3.7
uses: actions/setup-python@v2
- name: Set up Python 3.21
uses: actions/setup-python@v5
with:
python-version: '3.7'
python-version: '3.12'

- name: Update pip and install deps
run: |
python -m pip install setuptools
python -m pip install --upgrade pip
python -m pip install check-manifest flake8
python -m pip install check-manifest
python -m pip install -r requirements-dev.txt

- name: Check MANIFEST.in in a source package
run: check-manifest -v

- name: Static code analysis and code style check
run: flake8 ./
run: |
ruff check .
ruff format --check .
7 changes: 4 additions & 3 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, windows-latest, macos-10.15]
os: [ubuntu-latest, windows-latest, macos-10.15]

steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.8'
python-version: '3.12'

- name: Update pip and install deps
run: |
python -m pip install --upgrade pip pyinstaller wheel
python -m pip install setuptools
python -m pip install -r requirements.txt .

- name: Build binaries
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ recursive-exclude pyinstaller *

# Include requirements.txt for reproducible tests
include requirements.txt
include requirements.in/*.txt
include requirements-dev.txt

# Add templates for the management UI.
recursive-include etesync_dav/templates *
14 changes: 7 additions & 7 deletions etesync_dav/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@

"""

__copyright__ = 'Copyright (C) 2017-2021 Tom Hacohen'
__version__ = '0.32.1'
__license__ = 'GPL-3.0-only'
__author__ = 'Tom Hacohen'
__author_email__ = '[email protected]'
__url__ = 'https://github.com/etesync/etesync-dav'
__description__ = 'A CalDAV and CardDAV frontend for EteSync'
__copyright__ = "Copyright (C) 2017-2021 Tom Hacohen"
__version__ = "0.32.1"
__license__ = "GPL-3.0-only"
__author__ = "Tom Hacohen"
__author_email__ = "[email protected]"
__url__ = "https://github.com/etesync/etesync-dav"
__description__ = "A CalDAV and CardDAV frontend for EteSync"
31 changes: 16 additions & 15 deletions etesync_dav/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,26 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from appdirs import user_config_dir, user_data_dir
import os

LISTEN_ADDRESS = os.environ.get('ETESYNC_LISTEN_ADDRESS', 'localhost')
LISTEN_PORT = os.environ.get('ETESYNC_LISTEN_PORT', '37358')
from appdirs import user_config_dir, user_data_dir

LISTEN_ADDRESS = os.environ.get("ETESYNC_LISTEN_ADDRESS", "localhost")
LISTEN_PORT = os.environ.get("ETESYNC_LISTEN_PORT", "37358")

DEFAULT_HOSTS = '{}:{}'.format(LISTEN_ADDRESS, LISTEN_PORT)
DEFAULT_HOSTS = "{}:{}".format(LISTEN_ADDRESS, LISTEN_PORT)

SERVER_HOSTS = os.environ.get('ETESYNC_SERVER_HOSTS', DEFAULT_HOSTS)
LEGACY_CONFIG_DIR = os.environ.get('ETESYNC_CONFIG_DIR', user_config_dir("etesync-dav", "etesync"))
DATA_DIR = os.environ.get('ETESYNC_DATA_DIR', user_data_dir("etesync-dav", "etesync"))
SERVER_HOSTS = os.environ.get("ETESYNC_SERVER_HOSTS", DEFAULT_HOSTS)
LEGACY_CONFIG_DIR = os.environ.get("ETESYNC_CONFIG_DIR", user_config_dir("etesync-dav", "etesync"))
DATA_DIR = os.environ.get("ETESYNC_DATA_DIR", user_data_dir("etesync-dav", "etesync"))

ETESYNC_URL = os.environ.get('ETESYNC_URL', 'https://api.etebase.com/partner/etesync/')
LEGACY_ETESYNC_URL = os.environ.get('ETESYNC_URL', 'https://api.etesync.com/')
DATABASE_FILE = os.environ.get('ETESYNC_DATABASE_FILE', os.path.join(DATA_DIR, 'etesync_data.db'))
ETEBASE_DATABASE_FILE = os.environ.get('ETEBASE_DATABASE_FILE', os.path.join(DATA_DIR, 'etebase_data.db'))
ETESYNC_URL = os.environ.get("ETESYNC_URL", "https://api.etebase.com/partner/etesync/")
LEGACY_ETESYNC_URL = os.environ.get("ETESYNC_URL", "https://api.etesync.com/")
DATABASE_FILE = os.environ.get("ETESYNC_DATABASE_FILE", os.path.join(DATA_DIR, "etesync_data.db"))
ETEBASE_DATABASE_FILE = os.environ.get("ETEBASE_DATABASE_FILE", os.path.join(DATA_DIR, "etebase_data.db"))

HTPASSWD_FILE = os.path.join(DATA_DIR, 'htpaswd')
CREDS_FILE = os.path.join(DATA_DIR, 'etesync_creds')
HTPASSWD_FILE = os.path.join(DATA_DIR, "htpaswd")
CREDS_FILE = os.path.join(DATA_DIR, "etesync_creds")

SSL_KEY_FILE = os.path.join(DATA_DIR, 'etesync.key')
SSL_CERT_FILE = os.path.join(DATA_DIR, 'etesync.crt')
SSL_KEY_FILE = os.path.join(DATA_DIR, "etesync.key")
SSL_CERT_FILE = os.path.join(DATA_DIR, "etesync.crt")
44 changes: 26 additions & 18 deletions etesync_dav/local_cache/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import os

import msgpack
from etebase import Account, Client, CollectionAccessLevel, FetchOptions

from etebase import Account, Client, FetchOptions, CollectionAccessLevel
from etesync_dav import config

from . import db, models


COL_TYPES = ["etebase.vcard", "etebase.vevent", "etebase.vtodo"]


Expand All @@ -30,11 +29,12 @@ def msgpack_decode(content):
def batch(iterable, n=1):
length = len(iterable)
for ndx in range(0, length, n):
yield iterable[ndx:min(ndx + n, length)]
yield iterable[ndx : min(ndx + n, length)]


def get_millis():
import time

return int(round(time.time() * 1000))


Expand Down Expand Up @@ -65,26 +65,30 @@ def _init_db(self, db_path):
from playhouse.sqlite_ext import SqliteExtDatabase

directory = os.path.dirname(db_path)
if directory != '' and not os.path.exists(directory):
if directory != "" and not os.path.exists(directory):
os.makedirs(directory)

database = SqliteExtDatabase(db_path, pragmas={
'journal_mode': 'wal',
'foreign_keys': 1,
})
database = SqliteExtDatabase(
db_path,
pragmas={
"journal_mode": "wal",
"foreign_keys": 1,
},
)

self._set_db(database)

def _init_db_tables(self, database, additional_tables=None):
CURRENT_DB_VERSION = 1

database.create_tables([models.Config, models.User, models.CollectionEntity,
models.ItemEntity, models.HrefMapper], safe=True)
database.create_tables(
[models.Config, models.User, models.CollectionEntity, models.ItemEntity, models.HrefMapper], safe=True
)
if additional_tables:
database.create_tables(additional_tables, safe=True)

default_db_version = CURRENT_DB_VERSION
config, created = models.Config.get_or_create(defaults={'db_version': default_db_version})
config, created = models.Config.get_or_create(defaults={"db_version": default_db_version})

def sync(self):
self.sync_collection_list()
Expand Down Expand Up @@ -235,8 +239,12 @@ def get(self, uid):
with db.database_proxy:
col_mgr = self.etebase.get_collection_manager()
try:
return Collection(col_mgr, self.user.collections.where(
(models.CollectionEntity.uid == uid) & ~models.CollectionEntity.deleted).get())
return Collection(
col_mgr,
self.user.collections.where(
(models.CollectionEntity.uid == uid) & ~models.CollectionEntity.deleted
).get(),
)
except models.CollectionEntity.DoesNotExist as e:
raise DoesNotExist(e)

Expand Down Expand Up @@ -301,10 +309,10 @@ def get(self, uid):
with db.database_proxy:
item_mgr = self.col_mgr.get_item_manager(self.col)
try:
return Item(item_mgr,
self.cache_col.items.where(
(models.ItemEntity.uid == uid) & ~models.ItemEntity.deleted
).get())
return Item(
item_mgr,
self.cache_col.items.where((models.ItemEntity.uid == uid) & ~models.ItemEntity.deleted).get(),
)
except models.ItemEntity.DoesNotExist:
return None

Expand All @@ -323,7 +331,7 @@ def __init__(self, item_mgr, cache_item):

@property
def uid(self):
return self.meta['name']
return self.meta["name"]

# FIXME: cache
@property
Expand Down
14 changes: 5 additions & 9 deletions etesync_dav/local_cache/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class User(db.BaseModel):


class CollectionEntity(db.BaseModel):
local_user = pw.ForeignKeyField(User, backref='collections', on_delete='CASCADE')
local_user = pw.ForeignKeyField(User, backref="collections", on_delete="CASCADE")
# The uid of the collection (same as Etebase)
uid = pw.CharField(null=False, index=True)
eb_col = pw.BlobField()
Expand All @@ -24,13 +24,11 @@ class CollectionEntity(db.BaseModel):
local_stoken = pw.CharField(null=True, default=None)

class Meta:
indexes = (
(('local_user', 'uid'), True),
)
indexes = ((("local_user", "uid"), True),)


class ItemEntity(db.BaseModel):
collection = pw.ForeignKeyField(CollectionEntity, backref='items', on_delete='CASCADE')
collection = pw.ForeignKeyField(CollectionEntity, backref="items", on_delete="CASCADE")
# The uid of the content (vobject uid)
uid = pw.CharField(null=False, index=True)
eb_item = pw.BlobField()
Expand All @@ -39,11 +37,9 @@ class ItemEntity(db.BaseModel):
deleted = pw.BooleanField(null=False, default=False)

class Meta:
indexes = (
(('collection', 'uid'), True),
)
indexes = ((("collection", "uid"), True),)


class HrefMapper(db.BaseModel):
content = pw.ForeignKeyField(ItemEntity, primary_key=True, backref='href', on_delete='CASCADE')
content = pw.ForeignKeyField(ItemEntity, primary_key=True, backref="href", on_delete="CASCADE")
href = pw.CharField(null=False, index=True)
Loading
Loading