-
Notifications
You must be signed in to change notification settings - Fork 123
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 #83 from jerrymakesjelly/dev
Version 1.5.3
- Loading branch information
Showing
79 changed files
with
1,652 additions
and
990 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
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
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,35 @@ | ||
from .util.convertbytes import convert_bytes | ||
from .util.convertspeed import convert_speed | ||
|
||
class ClientStatus(object): | ||
def __init__(self): | ||
# Proper attributes: | ||
# free_space, total_download_speed, total_upload_speed, etc. | ||
# | ||
# Note: | ||
# The type of free_space is a function because we need to specific a | ||
# directory to check its free space. | ||
pass | ||
|
||
# Format client status info | ||
def __str__(self): | ||
# Attribute Formater | ||
def disp(prop, converter = None): | ||
if hasattr(self, prop): | ||
attr = getattr(self, prop) | ||
if converter is not None: | ||
return converter(attr) | ||
else: | ||
return '(Not Provided)' | ||
|
||
return ('Status reported by the client: \n' + | ||
'\tDownload Speed: %s\tTotal: %s\n' + | ||
'\tUpload Speed: %s\tTotal: %s\n' + | ||
'\tOutgoing Port Status: %s') % \ | ||
( | ||
disp('download_speed', convert_speed), | ||
disp('total_downloaded', convert_bytes), | ||
disp('upload_speed', convert_speed), | ||
disp('total_uploaded', convert_bytes), | ||
disp('port_status', lambda s: s.name), | ||
) |
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,23 @@ | ||
import sys | ||
|
||
# The shutil.disk_usage is available since Python 3.3, | ||
# but in other versions, we need to use psutil.disk_usage to replace it. | ||
# (For Synology's compatibility; there is no psutil in Python 3 in Synology) | ||
SUPPORT_SHUTIL = sys.version_info >= (3, 3, 0) | ||
|
||
def disk_usage_(path): | ||
du = None | ||
|
||
if SUPPORT_SHUTIL: | ||
import shutil | ||
du = shutil.disk_usage(path) | ||
else: | ||
import psutil | ||
du = psutil.disk_usage(path) | ||
|
||
# Unified format | ||
return { | ||
'total': du.total, | ||
'used': du.used, | ||
'free': du.free, | ||
} |
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
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
Oops, something went wrong.