Skip to content
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
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ dist: xenial

language: python
python:
- 2.7
- 3.4
- 3.6
- 3.7
- 3.8
cache:
pip: true
Expand All @@ -17,7 +17,7 @@ install:
- python setup.py sdist
before_script:
- pylint synology_dsm tests
- ./scripts/check_format.sh
- black --check --fast .
script:
- py.test

Expand Down
8 changes: 3 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
requests>=2.20.0
urllib3>=1.24.3,<1.25
six>=1.14.0
future>=0.18.2
simplejson>=3.16.0
requests>=2.24.0
# Constrain urllib3 to ensure we deal with CVE-2019-11236 & CVE-2019-11324
urllib3>=1.24.3
3 changes: 2 additions & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pytest
pylint>=1.9.5,<=2.4.4
pylint>=2.6.0
pylint-strict-informational==0.1
black==20.8b1
16 changes: 0 additions & 16 deletions scripts/check_format.sh

This file was deleted.

14 changes: 7 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Synology DSM setup."""

# NOTE(ProtoThis) Guidelines for Major.Minor.Micro
# - Major means an API contract change
# - Minor means API bugfix or new functionality
# - Micro means change of any kind (unless significant enough for a minor/major).

from setuptools import setup, find_packages
from codecs import open

REPO_URL = "https://github.com/ProtoThis/python-synology"
VERSION = "0.9.0"
Expand All @@ -25,23 +24,24 @@
download_url=REPO_URL + "/tarball/" + VERSION,
description="Python API for communication with Synology DSM",
long_description=long_description,
author="FG van Zeelst (ProtoThis)",
author="Quentin POLLET (Quentame) & FG van Zeelst (ProtoThis)",
packages=find_packages(include=["synology_dsm*"]),
install_requires=required,
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
python_requires=">=3.6",
license="MIT",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Software Development :: Libraries",
],
keywords=["synology-dsm", "synology"],
)
3 changes: 1 addition & 2 deletions synology_dsm/api/core/security.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
"""DSM Security data."""


class SynoCoreSecurity(object):
class SynoCoreSecurity:
"""Class containing Security data."""

API_KEY = "SYNO.Core.SecurityScan.Status"
Expand Down
3 changes: 1 addition & 2 deletions synology_dsm/api/core/share.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
"""Shared Folders data."""
from synology_dsm.helpers import SynoFormatHelper


class SynoCoreShare(object):
class SynoCoreShare:
"""Class containing Share data."""

API_KEY = "SYNO.Core.Share"
Expand Down
3 changes: 1 addition & 2 deletions synology_dsm/api/core/utilization.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
"""DSM Utilization data."""
from synology_dsm.helpers import SynoFormatHelper


class SynoCoreUtilization(object):
class SynoCoreUtilization:
"""Class containing Utilization data."""

API_KEY = "SYNO.Core.System.Utilization"
Expand Down
2 changes: 1 addition & 1 deletion synology_dsm/api/download_station/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from .task import SynoDownloadTask


class SynoDownloadStation(object):
class SynoDownloadStation:
"""An implementation of a Synology DownloadStation."""

API_KEY = "SYNO.DownloadStation.*"
Expand Down
2 changes: 1 addition & 1 deletion synology_dsm/api/download_station/task.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""DownloadStation task."""


class SynoDownloadTask(object):
class SynoDownloadTask:
"""An representation of a Synology DownloadStation task."""

def __init__(self, data):
Expand Down
3 changes: 1 addition & 2 deletions synology_dsm/api/dsm/information.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
"""DSM Information data."""


class SynoDSMInformation(object):
class SynoDSMInformation:
"""Class containing Information data."""

API_KEY = "SYNO.DSM.Info"
Expand Down
3 changes: 1 addition & 2 deletions synology_dsm/api/dsm/network.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
"""DSM Network data."""


class SynoDSMNetwork(object):
class SynoDSMNetwork:
"""Class containing Network data."""

API_KEY = "SYNO.DSM.Network"
Expand Down
4 changes: 1 addition & 3 deletions synology_dsm/api/storage/storage.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# -*- coding: utf-8 -*-
"""DSM Storage data."""
from __future__ import division

from synology_dsm.helpers import SynoFormatHelper


class SynoStorage(object):
class SynoStorage:
"""Class containing Storage data."""

API_KEY = "SYNO.Storage.CGI.Storage"
Expand Down
6 changes: 3 additions & 3 deletions synology_dsm/api/surveillance_station/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .const import MOTION_DETECTION_BY_SURVEILLANCE, MOTION_DETECTION_DISABLED


class SynoSurveillanceStation(object):
class SynoSurveillanceStation:
"""An implementation of a Synology SurveillanceStation."""

API_KEY = "SYNO.SurveillanceStation.*"
Expand Down Expand Up @@ -37,12 +37,12 @@ def update(self):
)["data"]
)

live_view_data = self._dsm.get(
live_view_datas = self._dsm.get(
self.CAMERA_API_KEY,
"GetLiveViewPath",
{"idList": ",".join(str(k) for k in self._cameras_by_id)},
)["data"]
for live_view_data in live_view_data:
for live_view_data in live_view_datas:
self._cameras_by_id[live_view_data["id"]].live_view.update(live_view_data)

# Global
Expand Down
4 changes: 2 additions & 2 deletions synology_dsm/api/surveillance_station/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from .const import RECORDING_STATUS, MOTION_DETECTION_DISABLED


class SynoCamera(object):
class SynoCamera:
"""An representation of a Synology SurveillanceStation camera."""

def __init__(self, data, live_view_data=None):
Expand Down Expand Up @@ -62,7 +62,7 @@ def is_recording(self):
return self._data["recStatus"] in RECORDING_STATUS


class SynoCameraLiveView(object):
class SynoCameraLiveView:
"""An representation of a Synology SurveillanceStation camera live view."""

def __init__(self, data):
Expand Down
1 change: 0 additions & 1 deletion synology_dsm/const.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Library constants."""

# APIs
Expand Down
30 changes: 14 additions & 16 deletions synology_dsm/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Library exceptions."""
from .const import API_AUTH, ERROR_AUTH, ERROR_COMMON, ERROR_DOWNLOAD_SEARCH, ERROR_DOWNLOAD_TASK, ERROR_FILE, ERROR_SURVEILLANCE, ERROR_VIRTUALIZATION

Expand All @@ -24,7 +23,7 @@ def __init__(self, api, code, details=None):
reason = "Unknown"

error_message={"api": api, "code": code, "reason": reason, "details": details}
super(SynologyDSMException, self).__init__(error_message)
super().__init__(error_message)

# Request
class SynologyDSMRequestException(SynologyDSMException):
Expand All @@ -34,57 +33,56 @@ def __init__(self, exception):
ex_reason = exception.args[0]
if hasattr(exception.args[0], "reason"):
ex_reason = exception.args[0].reason
message = "%s = %s" % (ex_class, ex_reason)
super(SynologyDSMRequestException, self).__init__(None, -1, message)
super().__init__(None, -1, f"{ex_class} = {ex_reason}")

# API
class SynologyDSMAPINotExistsException(SynologyDSMException):
"""API not exists exception."""
def __init__(self, api):
super(SynologyDSMAPINotExistsException, self).__init__(api, -2, "API %s does not exists" % api)
super().__init__(api, -2, f"API {api} does not exists")

class SynologyDSMAPIErrorException(SynologyDSMException):
"""API returns an error exception."""
def __init__(self, api, code, details):
super(SynologyDSMAPIErrorException, self).__init__(api, code, details)
super().__init__(api, code, details)

# Login
class SynologyDSMLoginFailedException(SynologyDSMException):
"""Failed to login exception."""
def __init__(self, code, details=None):
super(SynologyDSMLoginFailedException, self).__init__(API_AUTH, code, details)
super().__init__(API_AUTH, code, details)


class SynologyDSMLoginInvalidException(SynologyDSMLoginFailedException):
"""Invalid password & not admin account exception."""
def __init__(self, username):
message = "Invalid password or not admin account: %s" % username
super(SynologyDSMLoginInvalidException, self).__init__(400, message)
message = f"Invalid password or not admin account: {username}"
super().__init__(400, message)


class SynologyDSMLoginDisabledAccountException(SynologyDSMLoginFailedException):
"""Guest & disabled account exception."""
def __init__(self, username):
message = "Guest or disabled account: %s" % username
super(SynologyDSMLoginDisabledAccountException, self).__init__(401, message)
message = f"Guest or disabled account: {username}"
super().__init__(401, message)


class SynologyDSMLoginPermissionDeniedException(SynologyDSMLoginFailedException):
"""No access to login exception."""
def __init__(self, username):
message = "Permission denied for account: %s" % username
super(SynologyDSMLoginPermissionDeniedException, self).__init__(402, message)
message = f"Permission denied for account: {username}"
super().__init__(402, message)


class SynologyDSMLogin2SARequiredException(SynologyDSMLoginFailedException):
"""2SA required to login exception."""
def __init__(self, username):
message = "Two-step authentication required for account: %s" % username
super(SynologyDSMLogin2SARequiredException, self).__init__(403, message)
message = f"Two-step authentication required for account: {username}"
super().__init__(403, message)


class SynologyDSMLogin2SAFailedException(SynologyDSMLoginFailedException):
"""2SA code failed exception."""
def __init__(self):
message = "Two-step authentication failed, retry with a new pass code"
super(SynologyDSMLogin2SAFailedException, self).__init__(404, message)
super().__init__(404, message)
3 changes: 1 addition & 2 deletions synology_dsm/helpers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
"""Helpers."""


class SynoFormatHelper(object):
class SynoFormatHelper:
"""Class containing various formatting functions."""

@staticmethod
Expand Down
Loading