From 125d4684bd4a538f46fe88f6d1a4d215645d8f29 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 17 Nov 2020 01:22:29 +0330 Subject: [PATCH 1/9] fix : DEBUG param renamed to debug --- orangetool/orangetool_display.py | 32 ++++++------- orangetool/orangetool_ip.py | 40 ++++++++-------- orangetool/orangetool_ram.py | 8 ++-- orangetool/orangetool_storage.py | 40 ++++++++-------- orangetool/orangetool_system.py | 80 ++++++++++++++++---------------- 5 files changed, 100 insertions(+), 100 deletions(-) diff --git a/orangetool/orangetool_display.py b/orangetool/orangetool_display.py index 5042cd9..e492b02 100644 --- a/orangetool/orangetool_display.py +++ b/orangetool/orangetool_display.py @@ -2,14 +2,14 @@ """Orangetool display functions.""" -def hdmi_controller(command, DEBUG=False): +def hdmi_controller(command, debug=False): """ Control hdmi port. :param command: inpurt command :type command: bool - :param DEBUG: flag for using Debug mode - :type DEBUG: bool + :param debug: flag for using Debug mode + :type debug: bool :return: bool """ try: @@ -21,43 +21,43 @@ def hdmi_controller(command, DEBUG=False): hdmi_control.close() return True except Exception as e: - if DEBUG: + if debug: print(str(e)) return "Error" -def hdmi_on(DEBUG=False): +def hdmi_on(debug=False): """ Turn on hdmi port (need sudo -s). - :param DEBUG: flag for using Debug mode - :type DEBUG:bool + :param debug: flag for using Debug mode + :type debug:bool :return: bool """ - hdmi_controller(True, DEBUG) + hdmi_controller(True, debug) -def hdmi_off(DEBUG=False): +def hdmi_off(debug=False): """ Turn off hdmi port (need sudo -s). - :param DEBUG: flag for using Debug mode - :type DEBUG:bool + :param debug: flag for using Debug mode + :type debug:bool :return: bool """ - hdmi_controller(False, DEBUG) + hdmi_controller(False, debug) -def hdmi_size(v=None, h=None, DEBUG=False): +def hdmi_size(v=None, h=None, debug=False): """ Change hdmi display resolution (need sudo -s) (if call without any argument return current resolution). :param v: vertical line :param h: horizental line - :param DEBUG: flag for using Debug mode + :param debug: flag for using Debug mode :type v : int :type h:int - :type DEBUG:bool + :type debug:bool :return: bool """ try: @@ -71,6 +71,6 @@ def hdmi_size(v=None, h=None, DEBUG=False): hdmi_control.close() return True except Exception as e: - if DEBUG: + if debug: print(str(e)) return "Error" diff --git a/orangetool/orangetool_ip.py b/orangetool/orangetool_ip.py index e872ba1..59b862f 100644 --- a/orangetool/orangetool_ip.py +++ b/orangetool/orangetool_ip.py @@ -36,12 +36,12 @@ def internet(host="8.8.8.8", port=53, timeout=3): return False -def local_ip(DEBUG=False): +def local_ip(debug=False): """ Return local ip of computer in windows by socket module and in unix with hostname command in shell. - :param DEBUG:flag for using Debug Mode - :type DEBUG:bool + :param debug:flag for using Debug Mode + :type debug:bool :return: local ip as string """ try: @@ -62,17 +62,17 @@ def local_ip(DEBUG=False): return "Error" except Exception as e: - if DEBUG: + if debug: print(str(e)) return "Error" -def global_ip(DEBUG=False): +def global_ip(debug=False): """ Return ip with by http://ipinfo.io/ip api. - :param DEBUG:flag for using Debug mode - :type DEBUG:bool + :param debug:flag for using Debug mode + :type debug:bool :return: global ip as string """ try: @@ -82,12 +82,12 @@ def global_ip(DEBUG=False): new_session.close() return ip_list[0] except Exception as e: - if DEBUG: + if debug: print(str(e)) return "Error" -def set_ip(ip, restart=False, device="eth0", DEBUG=False): +def set_ip(ip, restart=False, device="eth0", debug=False): """ Set static ip in interfaces file (need sudo). @@ -97,8 +97,8 @@ def set_ip(ip, restart=False, device="eth0", DEBUG=False): :type device:str :param ip: static ip :type ip :str - :param DEBUG: flag for using Debug mode - :type DEBUG:bool + :param debug: flag for using Debug mode + :type debug:bool :return: True in successful """ static_string = ''' @@ -125,21 +125,21 @@ def set_ip(ip, restart=False, device="eth0", DEBUG=False): restart_func() return True except Exception as e: - if DEBUG: + if debug: print(str(e)) return "Error" -def ping(ip, packet_number=3, DEBUG=False): +def ping(ip, packet_number=3, debug=False): """ Ping ip and return True if this ip is available and False otherwise. :param ip: target ip :param packet_number: number of packet to size - :param DEBUG: flag for using Debug mode + :param debug: flag for using Debug mode :type ip :str :type packet_number:int - :type DEBUG:bool + :type debug:bool :return: a boolean value (True if ip is available and False otherwise) """ try: @@ -155,17 +155,17 @@ def ping(ip, packet_number=3, DEBUG=False): return True return False except Exception as e: - if DEBUG: + if debug: print(str(e)) return "Error" -def mac(DEBUG=False): +def mac(debug=False): """ Return mac addresses of net devices. - :param DEBUG: flag for using Debug mode - :type DEBUG:bool + :param debug: flag for using Debug mode + :type debug:bool :return: return mac addresses as dict with name as keys and mac addresses as values """ try: @@ -178,6 +178,6 @@ def mac(DEBUG=False): mac_addr.close() return dict(zip(dir_list, mac_list)) except Exception as e: - if DEBUG: + if debug: print(str(e)) return "Error" diff --git a/orangetool/orangetool_ram.py b/orangetool/orangetool_ram.py index d08ea3e..6f69a0f 100644 --- a/orangetool/orangetool_ram.py +++ b/orangetool/orangetool_ram.py @@ -75,12 +75,12 @@ def ram_percent(): return str(response[2]) + " %" -def freeup(DEBUG=False): +def freeup(debug=False): """ To free pagecache, dentries and inodes. - :param DEBUG: flag for using Debug mode - :type DEBUG:bool + :param debug: flag for using Debug mode + :type debug:bool :return: Amount of freeuped ram as string and converted by convert_bytes() """ try: @@ -94,6 +94,6 @@ def freeup(DEBUG=False): return convert_bytes(freeuped_ram) return convert_bytes(0) except Exception as e: - if DEBUG: + if debug: print(str(e)) return "Error" diff --git a/orangetool/orangetool_storage.py b/orangetool/orangetool_storage.py index c8cd746..8318ff4 100644 --- a/orangetool/orangetool_storage.py +++ b/orangetool/orangetool_storage.py @@ -6,12 +6,12 @@ import random -def mount_status(device_name, DEBUG=False): +def mount_status(device_name, debug=False): """ Return addresses of mounted memory devices in dev by device name. - :param DEBUG: flag for using Debug mode - :type DEBUG:bool + :param debug: flag for using Debug mode + :type debug:bool :return: list of memory devices """ try: @@ -27,17 +27,17 @@ def mount_status(device_name, DEBUG=False): else: return memory_list except Exception as e: - if DEBUG: + if debug: print(str(e)) return "Error" -def storage_status(DEBUG=False): +def storage_status(debug=False): """ Return all of the inserted memory and their status. - :param DEBUG: flag for using Debug mode - :type DEBUG:bool + :param debug: flag for using Debug mode + :type debug:bool :return: all of the inserted memory and their status as dictionary ( device name as keys and mount status (mounted_addresses as list and u --> unmounted) as values """ try: @@ -51,19 +51,19 @@ def storage_status(DEBUG=False): memory_status.append(mount_status(item)) return dict(zip(memory_items, memory_status)) except Exception as e: - if DEBUG: + if debug: print(str(e)) return "Error" -def unmount(ADDRESS, DEBUG=False): +def unmount(ADDRESS, debug=False): """ Unmount memory devices by addresses. :param ADDRESS: address of that device mount on :type ADDRESS:str - :param DEBUG: flag for using Debug mode - :type DEBUG:bool + :param debug: flag for using Debug mode + :type debug:bool :return: True if device unmount correctly and False other wise """ try: @@ -74,17 +74,17 @@ def unmount(ADDRESS, DEBUG=False): return True return False except Exception as e: - if DEBUG: + if debug: print(str(e)) return "Error" -def unmount_all(DEBUG=False): +def unmount_all(debug=False): """ Unmount all of the mounted devices. - :param DEBUG: flag for using Debug mode - :type DEBUG:bool + :param debug: flag for using Debug mode + :type debug:bool :return: return True if all of the mounted devices unmount correctly """ try: @@ -98,7 +98,7 @@ def unmount_all(DEBUG=False): unmount(j) return True except Exception as e: - if DEBUG: + if debug: print(str(e)) return "Error" @@ -119,16 +119,16 @@ def random_generator(number): return response -def mount(device_name, mount_address=None, DEBUG=False): +def mount(device_name, mount_address=None, debug=False): """ Mount memory devices by addresses. :param device_name: name of device for mounted example = sda1 :param mount_address: address for mounting device example = /mnt/usb , default value is None in this case function generate random number for mount folder name - :param DEBUG: flag for using Debug mode + :param debug: flag for using Debug mode :type device_name:str :type mount_address:str - :type DEBUG:bool + :type debug:bool :return: True if device mount correctly and False other wise """ try: @@ -148,6 +148,6 @@ def mount(device_name, mount_address=None, DEBUG=False): return True return False except Exception as e: - if DEBUG: + if debug: print(str(e)) return "Error" diff --git a/orangetool/orangetool_system.py b/orangetool/orangetool_system.py index 2d4b02b..42849a3 100644 --- a/orangetool/orangetool_system.py +++ b/orangetool/orangetool_system.py @@ -10,12 +10,12 @@ UPDATE_URL = "http://www.orangetool.ir/version" -def check_update(DEBUG=False): +def check_update(debug=False): """ Check orangetool site for new version. - :param DEBUG: flag for using Debug mode - :type DEBUG:bool + :param debug: flag for using Debug mode + :type debug:bool :return: True if new version is available """ try: @@ -26,18 +26,18 @@ def check_update(DEBUG=False): print("Update!") return False except Exception as e: - if DEBUG: + if debug: print(str(e)) return "Error" -def get_temp(Zone=0, DEBUG=False): +def get_temp(Zone=0, debug=False): """ Read cpu temperature. - :param DEBUG : flag for using Debug mode + :param debug : flag for using Debug mode :param Zone : thermal Zone Index - :type DEBUG:bool + :type debug:bool :type Zone:int :return: board temp as string in celsius """ @@ -52,7 +52,7 @@ def get_temp(Zone=0, DEBUG=False): # else: # return "Error" except Exception as e: - if DEBUG: + if debug: print(str(e)) return "Error" @@ -89,12 +89,12 @@ def time_convert(input_string): zero_insert(str(input_minute)) + " minutes, " + zero_insert(str(input_sec)) + " seconds" -def uptime(DEBUG=False): +def uptime(debug=False): """ Return system uptime. - :param DEBUG: flag for using Debug mode - :type DEBUG:bool + :param debug: flag for using Debug mode + :type debug:bool :return: system uptime as string """ try: @@ -102,17 +102,17 @@ def uptime(DEBUG=False): response = command.read() return time_convert(response[:-1].split(" ")[0]) except Exception as e: - if DEBUG: + if debug: print(str(e)) return "Error" -def idletime(DEBUG=False): +def idletime(debug=False): """ Return system idletime. - :param DEBUG: flag for using Debug mode - :type DEBUG:bool + :param debug: flag for using Debug mode + :type debug:bool :return: system idle as string """ try: @@ -120,7 +120,7 @@ def idletime(DEBUG=False): response = command.read() return time_convert(response[:-1].split(" ")[1]) except Exception as e: - if DEBUG: + if debug: print(str(e)) return "Error" @@ -135,18 +135,18 @@ def version(): tprint("v"+VERSION,font="bulbhead") -def wakeup(day=0, hour=0, minute=0, DEBUG=False): +def wakeup(day=0, hour=0, minute=0, debug=False): """ Set wakeup time for kernel RTC (need sudo). :param day: days for wakeup :param hour: hout for wakeup :param minute: minute for wakeup - :param DEBUG: flag for using Debug mode + :param debug: flag for using Debug mode :type day:int :type hour:int :type minute:int - :type DEBUG:bool + :type debug:bool :return: bool """ try: @@ -160,19 +160,19 @@ def wakeup(day=0, hour=0, minute=0, DEBUG=False): file.close() return True except Exception as e: - if DEBUG: + if debug: print(str(e)) return "Error" -def power_control(command, DEBUG=False): +def power_control(command, debug=False): """ Control different power options. :param command: input command :type command: str - :param DEBUG: flag for using Debug mode - :type DEBUG: bool + :param debug: flag for using Debug mode + :type debug: bool :return: None """ try: @@ -185,49 +185,49 @@ def power_control(command, DEBUG=False): if len(response[1]) > 0: raise Exception('Root Error') except Exception as e: - if DEBUG: + if debug: print(str(e)) return "Error" -def sleep(DEBUG=False): +def sleep(debug=False): """ Shortcut for sleep command (need sudo). - :param DEBUG: flag for using Debug mode - :type DEBUG:bool + :param debug: flag for using Debug mode + :type debug:bool :return: None """ - power_control("pm-suspend", DEBUG) + power_control("pm-suspend", debug) -def hibernate(DEBUG=False): +def hibernate(debug=False): """ Shortcut for hibernate command (need sudo). - :param DEBUG: flag for using Debug mode - :type DEBUG:bool + :param debug: flag for using Debug mode + :type debug:bool :return: None """ - power_control("pm-hibernate", DEBUG) + power_control("pm-hibernate", debug) -def halt(DEBUG=False): +def halt(debug=False): """ Shortcut for poweroff (need sudo). - :param DEBUG: flag for using Debug mode - :type DEBUG:bool + :param debug: flag for using Debug mode + :type debug:bool :return: None """ - power_control("poweroff", DEBUG) + power_control("poweroff", debug) -def restart(DEBUG=False): +def restart(debug=False): """ Shortcut for reboot (need sudo). - :param DEBUG: flag for using Debug mode - :type DEBUG:bool + :param debug: flag for using Debug mode + :type debug:bool :return: None """ - power_control("reboot", DEBUG) + power_control("reboot", debug) From b54c2f0f3ff74b92b3d0d330645d9472d225aa89 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 17 Nov 2020 01:24:11 +0330 Subject: [PATCH 2/9] fix : __version__ added --- orangetool/__init__.py | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/orangetool/__init__.py b/orangetool/__init__.py index 30253fa..84619cb 100644 --- a/orangetool/__init__.py +++ b/orangetool/__init__.py @@ -1,31 +1,10 @@ # -*- coding: utf-8 -*- """Orangetool modules.""" -""" -MIT License - -Copyright (c) 2017 Moduland Co - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -""" from .orangetool_display import * from .orangetool_ip import * from .orangetool_system import * from .orangetool_ram import * from .orangetool_storage import * + +__version__ = VERSION From 3d079159b9f7c88969c321abac70278e95391664 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 17 Nov 2020 01:24:55 +0330 Subject: [PATCH 3/9] doc : CHANGELOG updated --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec23200..513e4ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed - `dev-requirements.txt` modified - Test system modified +- `DEBUG` parameter renamed to `debug` ## [0.35] - 2019-06-01 ### Added - `version_check.py` From 9bd6c7646903b5d9838b61f0dbd41a3ddd4ae5c0 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 17 Nov 2020 01:27:22 +0330 Subject: [PATCH 4/9] fix : minor edit in setup.py --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index 53371e4..f73dab4 100644 --- a/setup.py +++ b/setup.py @@ -48,6 +48,8 @@ def read_description(): '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 :: Scientific/Engineering', ], install_requires=get_requires(), From fb6a7fbf95e5c5a6015e27c728a5f1dc3c381c74 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 17 Nov 2020 15:19:52 +0330 Subject: [PATCH 5/9] doc : CHANGELOG updated --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 513e4ca..7250c5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] ### Added - `FUNDING.yml` +- `__version__` variable - `hibernate` function ### Changed - `dev-requirements.txt` modified From b1085a0837f7fe7f5ce5948ee3f6687525a7878c Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Wed, 18 Nov 2020 02:00:50 +0330 Subject: [PATCH 6/9] doc : docstrings updated --- orangetool/orangetool_display.py | 8 ++++---- orangetool/orangetool_ip.py | 10 +++++----- orangetool/orangetool_ram.py | 2 +- orangetool/orangetool_storage.py | 10 +++++----- orangetool/orangetool_system.py | 20 ++++++++++---------- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/orangetool/orangetool_display.py b/orangetool/orangetool_display.py index e492b02..21703d2 100644 --- a/orangetool/orangetool_display.py +++ b/orangetool/orangetool_display.py @@ -8,7 +8,7 @@ def hdmi_controller(command, debug=False): :param command: inpurt command :type command: bool - :param debug: flag for using Debug mode + :param debug: flag for using debug mode :type debug: bool :return: bool """ @@ -30,7 +30,7 @@ def hdmi_on(debug=False): """ Turn on hdmi port (need sudo -s). - :param debug: flag for using Debug mode + :param debug: flag for using debug mode :type debug:bool :return: bool """ @@ -41,7 +41,7 @@ def hdmi_off(debug=False): """ Turn off hdmi port (need sudo -s). - :param debug: flag for using Debug mode + :param debug: flag for using debug mode :type debug:bool :return: bool """ @@ -54,7 +54,7 @@ def hdmi_size(v=None, h=None, debug=False): :param v: vertical line :param h: horizental line - :param debug: flag for using Debug mode + :param debug: flag for using debug mode :type v : int :type h:int :type debug:bool diff --git a/orangetool/orangetool_ip.py b/orangetool/orangetool_ip.py index 59b862f..fae4700 100644 --- a/orangetool/orangetool_ip.py +++ b/orangetool/orangetool_ip.py @@ -40,7 +40,7 @@ def local_ip(debug=False): """ Return local ip of computer in windows by socket module and in unix with hostname command in shell. - :param debug:flag for using Debug Mode + :param debug:flag for using debug Mode :type debug:bool :return: local ip as string """ @@ -71,7 +71,7 @@ def global_ip(debug=False): """ Return ip with by http://ipinfo.io/ip api. - :param debug:flag for using Debug mode + :param debug:flag for using debug mode :type debug:bool :return: global ip as string """ @@ -97,7 +97,7 @@ def set_ip(ip, restart=False, device="eth0", debug=False): :type device:str :param ip: static ip :type ip :str - :param debug: flag for using Debug mode + :param debug: flag for using debug mode :type debug:bool :return: True in successful """ @@ -136,7 +136,7 @@ def ping(ip, packet_number=3, debug=False): :param ip: target ip :param packet_number: number of packet to size - :param debug: flag for using Debug mode + :param debug: flag for using debug mode :type ip :str :type packet_number:int :type debug:bool @@ -164,7 +164,7 @@ def mac(debug=False): """ Return mac addresses of net devices. - :param debug: flag for using Debug mode + :param debug: flag for using debug mode :type debug:bool :return: return mac addresses as dict with name as keys and mac addresses as values """ diff --git a/orangetool/orangetool_ram.py b/orangetool/orangetool_ram.py index 6f69a0f..05f3598 100644 --- a/orangetool/orangetool_ram.py +++ b/orangetool/orangetool_ram.py @@ -79,7 +79,7 @@ def freeup(debug=False): """ To free pagecache, dentries and inodes. - :param debug: flag for using Debug mode + :param debug: flag for using debug mode :type debug:bool :return: Amount of freeuped ram as string and converted by convert_bytes() """ diff --git a/orangetool/orangetool_storage.py b/orangetool/orangetool_storage.py index 8318ff4..dc7b0e0 100644 --- a/orangetool/orangetool_storage.py +++ b/orangetool/orangetool_storage.py @@ -10,7 +10,7 @@ def mount_status(device_name, debug=False): """ Return addresses of mounted memory devices in dev by device name. - :param debug: flag for using Debug mode + :param debug: flag for using debug mode :type debug:bool :return: list of memory devices """ @@ -36,7 +36,7 @@ def storage_status(debug=False): """ Return all of the inserted memory and their status. - :param debug: flag for using Debug mode + :param debug: flag for using debug mode :type debug:bool :return: all of the inserted memory and their status as dictionary ( device name as keys and mount status (mounted_addresses as list and u --> unmounted) as values """ @@ -62,7 +62,7 @@ def unmount(ADDRESS, debug=False): :param ADDRESS: address of that device mount on :type ADDRESS:str - :param debug: flag for using Debug mode + :param debug: flag for using debug mode :type debug:bool :return: True if device unmount correctly and False other wise """ @@ -83,7 +83,7 @@ def unmount_all(debug=False): """ Unmount all of the mounted devices. - :param debug: flag for using Debug mode + :param debug: flag for using debug mode :type debug:bool :return: return True if all of the mounted devices unmount correctly """ @@ -125,7 +125,7 @@ def mount(device_name, mount_address=None, debug=False): :param device_name: name of device for mounted example = sda1 :param mount_address: address for mounting device example = /mnt/usb , default value is None in this case function generate random number for mount folder name - :param debug: flag for using Debug mode + :param debug: flag for using debug mode :type device_name:str :type mount_address:str :type debug:bool diff --git a/orangetool/orangetool_system.py b/orangetool/orangetool_system.py index 42849a3..9d844cb 100644 --- a/orangetool/orangetool_system.py +++ b/orangetool/orangetool_system.py @@ -14,7 +14,7 @@ def check_update(debug=False): """ Check orangetool site for new version. - :param debug: flag for using Debug mode + :param debug: flag for using debug mode :type debug:bool :return: True if new version is available """ @@ -35,7 +35,7 @@ def get_temp(Zone=0, debug=False): """ Read cpu temperature. - :param debug : flag for using Debug mode + :param debug : flag for using debug mode :param Zone : thermal Zone Index :type debug:bool :type Zone:int @@ -93,7 +93,7 @@ def uptime(debug=False): """ Return system uptime. - :param debug: flag for using Debug mode + :param debug: flag for using debug mode :type debug:bool :return: system uptime as string """ @@ -111,7 +111,7 @@ def idletime(debug=False): """ Return system idletime. - :param debug: flag for using Debug mode + :param debug: flag for using debug mode :type debug:bool :return: system idle as string """ @@ -142,7 +142,7 @@ def wakeup(day=0, hour=0, minute=0, debug=False): :param day: days for wakeup :param hour: hout for wakeup :param minute: minute for wakeup - :param debug: flag for using Debug mode + :param debug: flag for using debug mode :type day:int :type hour:int :type minute:int @@ -171,7 +171,7 @@ def power_control(command, debug=False): :param command: input command :type command: str - :param debug: flag for using Debug mode + :param debug: flag for using debug mode :type debug: bool :return: None """ @@ -194,7 +194,7 @@ def sleep(debug=False): """ Shortcut for sleep command (need sudo). - :param debug: flag for using Debug mode + :param debug: flag for using debug mode :type debug:bool :return: None """ @@ -204,7 +204,7 @@ def hibernate(debug=False): """ Shortcut for hibernate command (need sudo). - :param debug: flag for using Debug mode + :param debug: flag for using debug mode :type debug:bool :return: None """ @@ -215,7 +215,7 @@ def halt(debug=False): """ Shortcut for poweroff (need sudo). - :param debug: flag for using Debug mode + :param debug: flag for using debug mode :type debug:bool :return: None """ @@ -226,7 +226,7 @@ def restart(debug=False): """ Shortcut for reboot (need sudo). - :param debug: flag for using Debug mode + :param debug: flag for using debug mode :type debug:bool :return: None """ From 33ca44c91756b4c5b49f6ab79d58106619284525 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Fri, 20 Nov 2020 14:00:40 +0330 Subject: [PATCH 7/9] fix : VERSION renamed to ORANGETOOL_VERSION --- orangetool/orangetool_system.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/orangetool/orangetool_system.py b/orangetool/orangetool_system.py index 9d844cb..285be4e 100644 --- a/orangetool/orangetool_system.py +++ b/orangetool/orangetool_system.py @@ -6,7 +6,7 @@ from art import tprint ip_pattern = r"(?:[0-9]{1,3}\.){3}[0-9]{1,3}" api_1 = "http://ipinfo.io/ip" -VERSION = "0.35" +ORANGETOOL_VERSION = "0.35" UPDATE_URL = "http://www.orangetool.ir/version" @@ -20,7 +20,7 @@ def check_update(debug=False): """ try: new_version = requests.get(UPDATE_URL).text - if float(new_version) > float(VERSION): + if float(new_version) > float(ORANGETOOL_VERSION): print("New Version (" + new_version + ") Of Orangetool Is Available") return True print("Update!") @@ -132,7 +132,7 @@ def version(): :return: return orangetool-version number as string """ tprint("orangetool", font="bulbhead") - tprint("v"+VERSION,font="bulbhead") + tprint("v"+ORANGETOOL_VERSION,font="bulbhead") def wakeup(day=0, hour=0, minute=0, debug=False): From 192f6ff9215bc786b6724ef240a1b3999584bd8b Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Fri, 20 Nov 2020 14:04:54 +0330 Subject: [PATCH 8/9] fix : variables uppercased --- orangetool/orangetool_ip.py | 12 ++++++------ orangetool/orangetool_system.py | 3 +-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/orangetool/orangetool_ip.py b/orangetool/orangetool_ip.py index fae4700..1a70160 100644 --- a/orangetool/orangetool_ip.py +++ b/orangetool/orangetool_ip.py @@ -7,8 +7,8 @@ import requests import re import platform -ip_pattern = r"(?:[0-9]{1,3}\.){3}[0-9]{1,3}" -api_1 = "http://ipinfo.io/ip" +IP_PATTERN = r"(?:[0-9]{1,3}\.){3}[0-9]{1,3}" +GLOBAL_IP_API_1 = "http://ipinfo.io/ip" def internet(host="8.8.8.8", port=53, timeout=3): @@ -77,8 +77,8 @@ def global_ip(debug=False): """ try: new_session = requests.session() - response = new_session.get(api_1) - ip_list = re.findall(ip_pattern, response.text) + response = new_session.get(GLOBAL_IP_API_1) + ip_list = re.findall(IP_PATTERN, response.text) new_session.close() return ip_list[0] except Exception as e: @@ -111,7 +111,7 @@ def set_ip(ip, restart=False, device="eth0", debug=False): dns-nameservers 8.8.8.8 8.8.4.4 ''' try: - if bool(re.match(ip_pattern, ip)) == False or ip.find( + if bool(re.match(IP_PATTERN, ip)) == False or ip.find( "192.168.") == -1 or device not in mac().keys(): raise Exception("IP Formation Error") static_string = static_string.replace("ip", ip) @@ -143,7 +143,7 @@ def ping(ip, packet_number=3, debug=False): :return: a boolean value (True if ip is available and False otherwise) """ try: - if re.match(ip_pattern, ip) == False: + if re.match(IP_PATTERN, ip) == False: raise Exception("IP Formation Error") output = str(list(sub.Popen(["ping", ip, diff --git a/orangetool/orangetool_system.py b/orangetool/orangetool_system.py index 285be4e..0fb9eed 100644 --- a/orangetool/orangetool_system.py +++ b/orangetool/orangetool_system.py @@ -4,8 +4,7 @@ import time import requests from art import tprint -ip_pattern = r"(?:[0-9]{1,3}\.){3}[0-9]{1,3}" -api_1 = "http://ipinfo.io/ip" + ORANGETOOL_VERSION = "0.35" UPDATE_URL = "http://www.orangetool.ir/version" From f57eb447367aeab9ea64a78556c2b69373a28c6a Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Fri, 20 Nov 2020 14:05:44 +0330 Subject: [PATCH 9/9] fix : minor edit in __init__ --- orangetool/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orangetool/__init__.py b/orangetool/__init__.py index 84619cb..b6416d5 100644 --- a/orangetool/__init__.py +++ b/orangetool/__init__.py @@ -7,4 +7,4 @@ from .orangetool_ram import * from .orangetool_storage import * -__version__ = VERSION +__version__ = ORANGETOOL_VERSION