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

Tidy up in 2023 #418

Merged
merged 7 commits into from
Mar 11, 2023
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
14 changes: 6 additions & 8 deletions .github/workflows/code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@ name: Code CI

on:
push:
branches:
# Restricting to these branches and tags stops duplicate jobs on internal
# PRs but stops CI running on internal branches without a PR. Delete the
# next 5 lines to restore the original behaviour
- main
tags:
- "*"
pull_request:

jobs:
lint:
# pull requests are a duplicate of a branch push if within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: "ubuntu-latest"
steps:
- name: checkout
Expand All @@ -24,6 +19,7 @@ jobs:
tox -e pre-commit,mypy

wheel:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -57,6 +53,7 @@ jobs:
run: pipx run --python $(which python${{ matrix.python }}) --spec dist/*.whl ${GITHUB_REPOSITORY##*/} --version

test:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -219,7 +216,8 @@ jobs:
file: .devcontainer/Dockerfile
context: .
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8
push: ${{ github.event_name != 'pull_request' }}
# only push tagged builds
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
build-args: BASE=python:3.10-slim
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:

jobs:
docs:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
fail-fast: false
matrix:
Expand All @@ -34,7 +35,7 @@ jobs:
# Can delete this if you don't use graphviz in your docs
run: sudo apt-get install graphviz

- name: checkout
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This is the internal code reference for gphotos_sync
.. data:: gphotos_sync.__version__
:type: str

Version number as calculated by https://github.com/gilesknap-org/versiongit
Version number as calculated by setuptools_scm

.. automodule:: gphotos_sync.Main
:members:
Expand Down
20 changes: 10 additions & 10 deletions docs/tutorials/oauth2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ For a discussion of the purpose of this ID see `Tokens`.
Each step here assumes that you're logged into a personal Google account.

.. note::
The steps outlined here are correct as of May 2022. Their is quite a
bit of churn in the Google Cloud Console UI so the screens may change a
bit.
The steps outlined here are correct as of May 2022. Their is quite a
bit of churn in the Google Cloud Console UI so the screens may change a
bit.


Create a Google Cloud Project
Expand All @@ -32,17 +32,17 @@ Create a Google Cloud Project
.. image:: oauth-images/0.png
:align: center
:scale: 100 %

#. In the top banner the currently selected project is shown. If you have
no previous projects this will say 'Select a project'

* Click on the current project name or 'Select a project'

* This will bring up the 'Select a Project' dialog

.. image:: oauth-images/1.png
:align: center
:scale: 100
:scale: 100

#. Press **New Project**.
#. Enter a project name. For example, "gphotos". This name must be unique
Expand Down Expand Up @@ -147,15 +147,15 @@ Create the OAuth Credentials
:align: center
:scale: 75

#. Choose Desktop App
#. Choose Desktop App
#. Choose name for your credentials e.g. gphotos
#. Click **Create**

.. image:: oauth-images/14-create_id.png
:align: center
:scale: 75

#. Click **Download JSON** to download the OAuth client ID as JSON and
#. Click **Download JSON** to download the OAuth client ID as JSON and
save it as ``client_secret.json``.

.. image:: oauth-images/15-created.png
Expand All @@ -181,13 +181,13 @@ found in the README_.

.. _`the Google Cloud docs`: https://developers.google.com/identity/protocols/oauth2#expiration
.. _`Issue #290`: https://github.com/gilesknap/gphotos-sync/issues/290
.. _README: https://github.com/gilesknap/gphotos-sync/README.rst
.. _README: https://github.com/gilesknap/gphotos-sync/blob/main/README.rst


Move client_secret.json
-----------------------

#. The client_secret.json must be moved to the correct location
#. Each supported operating system has a different location where it will
#. Each supported operating system has a different location where it will
look for this file.
#. Return the `Tutorial` for details of where to put this file.
32 changes: 16 additions & 16 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,12 @@ setup_requires =
setuptools_scm[toml]>=6.2

install_requires =
attrs
exif
appdirs
requests_oauthlib
pyyaml>=4.2b1
types-PyYAML
psutil
google-auth-oauthlib>=1.0.0
types-requests
attrs==22.2.0
exif==1.6.0
appdirs==1.4.4
pyyaml==6.0
psutil==5.9.4
google-auth-oauthlib==1.0.0

[options.extras_require]
# For development tests/docs
Expand All @@ -50,9 +47,12 @@ dev =
pytest-cov
sphinx-rtd-theme-github-versions
tox
tox-direct
setuptools_scm[toml]>=6.2
mock
types-setuptools
types-requests
types-PyYAML

[options.packages.find]
where = src
Expand Down Expand Up @@ -122,20 +122,20 @@ source =
# Hence the use of allowlist_externals instead of using the tox virtualenvs.
# This ensures a match between developer time tools in the IDE and tox tools.
[tox:tox]
minversion = 3.7
skipsdist=true
skipinstall=true
skipsdist = True

[testenv:{pre-commit,mypy,pytest,docs}]
setenv =
QT_QPA_PLATFORM = offscreen
# Don't create a virtualenv for the command, requires tox-direct plugin
direct = True
passenv = *
allowlist_externals =
pytest
pre-commit
mypy
sphinx-build
sphinx-autobuild
commands =
pytest: pytest tests {posargs}
pytest: pytest {posargs}
mypy: mypy src tests {posargs}
pre-commit: pre-commit run --all-files {posargs}
docs: sphinx-build -EWT --keep-going docs build/html {posargs}
docs: sphinx-{posargs:build -EW --keep-going} -T docs build/html
4 changes: 2 additions & 2 deletions src/gphotos_sync/GooglePhotosDownload.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def __init__(
self.end_date: datetime = settings.end_date
self.retry_download: bool = settings.retry_download
self.case_insensitive_fs: bool = settings.case_insensitive_fs
self.video_timeout: int = 2000
self.image_timeout: int = 60
self.video_timeout: int = settings.video_timeout
self.image_timeout: int = settings.image_timeout

# attributes related to multi-threaded download
self.download_pool = futures.ThreadPoolExecutor(max_workers=self.max_threads)
Expand Down
14 changes: 14 additions & 0 deletions src/gphotos_sync/Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,18 @@ def __init__(self):
type=int,
default=8080,
)
parser.add_argument(
"--image-timeout",
help="Set the time in seconds to wait for an image to download",
type=int,
default=60,
)
parser.add_argument(
"--video-timeout",
help="Set the time in seconds to wait for a video to download",
type=int,
default=2000,
)
parser.add_help = True

def setup(self, args: Namespace, db_path: Path):
Expand Down Expand Up @@ -366,6 +378,8 @@ def setup(self, args: Namespace, db_path: Path):
ntfs_override=args.ntfs,
month_format=args.month_format,
path_format=args.path_format,
image_timeout=args.image_timeout,
video_timeout=args.video_timeout,
)

self.google_photos_client = RestClient(
Expand Down
3 changes: 3 additions & 0 deletions src/gphotos_sync/Settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ class Settings:

month_format: str
path_format: str

image_timeout: int
video_timeout: int