-
Notifications
You must be signed in to change notification settings - Fork 39
Add Core System and Upgrade APIs info and actions #72
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
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
0d993cc
add syno system data and actions
mib1185 1041b76
add system usage examples
mib1185 9e91ec0
add upgrade information
mib1185 ce8c2c4
Fix default login Exception (#73)
Quentame 212f029
Migrate to Python 3.6+ (#70)
Quentame 5244a49
correct alphabetically order
mib1185 1892770
add SynoCoreUpgrade instance
mib1185 97bc931
simplify update_available()
mib1185 5b63dfd
correct defaults of .get()
mib1185 abcb8f1
harmonize use of API_KEY
mib1185 bdfd8c8
update docs
mib1185 3c94ef3
add test data
mib1185 fbc2810
due to #70
mib1185 4e190d4
update docs
mib1185 34bf335
solve conflict
mib1185 d4c006c
add syno system data and actions
mib1185 b61e90d
add system usage examples
mib1185 8d6bef6
add upgrade information
mib1185 609bc32
correct alphabetically order
mib1185 2a3e609
add SynoCoreUpgrade instance
mib1185 13a63fa
simplify update_available()
mib1185 b878050
correct defaults of .get()
mib1185 aa217cf
harmonize use of API_KEY
mib1185 907e74c
update docs
mib1185 17016a9
add test data
mib1185 f9c8819
due to #70
mib1185 5d58f17
update docs
mib1185 c8775b7
Merge branch 'master' of https://github.com/mib1185/python-synology
mib1185 c6b337c
Apply suggestions from code review: function return type
Quentame 81bafb1
Don't save previous update data
Quentame File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,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 |
This file contains hidden or 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,3 +1,4 @@ | ||
| pytest | ||
| pylint>=1.9.5,<=2.4.4 | ||
| pylint>=2.6.0 | ||
| pylint-strict-informational==0.1 | ||
| black==20.8b1 |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,117 @@ | ||
| """DSM System data and actions.""" | ||
|
|
||
|
|
||
| class SynoCoreSystem: | ||
| """Class containing System data and actions.""" | ||
|
|
||
| API_KEY = "SYNO.Core.System" | ||
|
|
||
| def __init__(self, dsm): | ||
| self._dsm = dsm | ||
| self._data = {} | ||
|
|
||
| def update(self): | ||
| """Updates System data.""" | ||
| raw_data = self._dsm.get(self.API_KEY, "info") | ||
| if raw_data: | ||
| self._data = raw_data["data"] | ||
|
|
||
| ### get information | ||
| @property | ||
| def cpu_clock_speed(self): | ||
| """Gets System CPU clock speed.""" | ||
| return self._data.get('cpu_clock_speed') | ||
|
|
||
| @property | ||
| def cpu_cores(self): | ||
| """Gets System CPU cores.""" | ||
| return self._data.get('cpu_cores') | ||
|
|
||
| @property | ||
| def cpu_family(self): | ||
| """Gets System CPU family.""" | ||
| return self._data.get('cpu_family') | ||
|
|
||
| @property | ||
| def cpu_series(self): | ||
| """Gets System CPU series.""" | ||
| return self._data.get('cpu_series') | ||
|
|
||
| @property | ||
| def enabled_ntp(self): | ||
| """Gets System NTP state.""" | ||
| return self._data.get('enabled_ntp') | ||
|
|
||
| @property | ||
| def ntp_server(self): | ||
| """Gets System NTP server.""" | ||
| return self._data.get('ntp_server') | ||
|
|
||
| @property | ||
| def firmware_ver(self): | ||
| """Gets System firmware version.""" | ||
| return self._data.get('firmware_ver') | ||
|
|
||
| @property | ||
| def model(self): | ||
| """Gets System model.""" | ||
| return self._data.get('model') | ||
|
|
||
| @property | ||
| def ram_size(self): | ||
| """Gets System ram size.""" | ||
| return self._data.get('ram_size') | ||
|
|
||
| @property | ||
| def serial(self): | ||
| """Gets System serial number.""" | ||
| return self._data.get('serial') | ||
|
|
||
| @property | ||
| def sys_temp(self): | ||
| """Gets System temperature.""" | ||
| return self._data.get('sys_temp') | ||
|
|
||
| @property | ||
| def time(self): | ||
| """Gets System time.""" | ||
| return self._data.get('time') | ||
|
|
||
| @property | ||
| def time_zone(self): | ||
| """Gets System time zone.""" | ||
| return self._data.get('time_zone') | ||
|
|
||
| @property | ||
| def time_zone_desc(self): | ||
| """Gets System time zone description.""" | ||
| return self._data.get('time_zone_desc') | ||
|
|
||
| @property | ||
| def up_time(self): | ||
| """Gets System uptime.""" | ||
| return self._data.get('up_time') | ||
|
|
||
| @property | ||
| def usb_dev(self): | ||
| """Gets System connected usb devices.""" | ||
| return self._data.get('usb_dev', []) | ||
|
|
||
| ### do system actions | ||
| def shutdown(self): | ||
| """Shutdown NAS.""" | ||
| res = self._dsm.get( | ||
| self.API_KEY, | ||
| "shutdown", | ||
| max_version=1, # shutdown method is only available on api version 1 | ||
| ) | ||
| return res | ||
|
|
||
| def reboot(self): | ||
| """Reboot NAS.""" | ||
| res = self._dsm.get( | ||
| self.API_KEY, | ||
| "reboot", | ||
| max_version=1, # reboot method is only available on api version 1 | ||
| ) | ||
| return res |
This file contains hidden or 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,23 @@ | ||
| """DSM Upgrade data and actions.""" | ||
|
|
||
|
|
||
| class SynoCoreUpgrade: | ||
| """Class containing upgrade data and actions.""" | ||
|
|
||
| API_KEY = "SYNO.Core.Upgrade" | ||
| API_SERVER_KEY = API_KEY + ".Server" | ||
|
|
||
| def __init__(self, dsm): | ||
| self._dsm = dsm | ||
| self._data = {} | ||
|
|
||
| def update(self): | ||
| """Updates Upgrade data.""" | ||
| raw_data = self._dsm.get(self.API_SERVER_KEY, "check") | ||
| if raw_data: | ||
| self._data = raw_data["data"] | ||
|
|
||
| @property | ||
| def update_available(self): | ||
Quentame marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """Gets all Upgrade info.""" | ||
| return self._data["update"].get("available") | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.