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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- `FUNDING.yml`
- `__version__` variable
- `hibernate` function
- `usb_control`, `usb_on` and `usb_off` functions
### Changed
- `dev-requirements.txt` modified
- Test system modified
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,14 @@ orangetool.unmount_all() #This function unmount all of the mounted devices

orangetool.mount("sda1","/mnt/usb1") # This function mount input device in input addresses

#6- usb_on

orangetool.usb_on() # This function enable USB

#7- usb_off

orangetool.usb_off() # This function disable USB

```

### Display Functions
Expand Down
47 changes: 47 additions & 0 deletions orangetool/orangetool_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,50 @@ def mount(device_name, mount_address=None, debug=False):
if debug:
print(str(e))
return "Error"


def usb_control(code, debug=False):
"""
Control different usb options.

:param code: permission code
:type code: str
:param debug: flag for using debug mode
:type debug: bool
:return: None
"""
try:
command = sub.Popen(
["chmod", "-R", code,"/media/"],
stderr=sub.PIPE,
stdout=sub.PIPE,
stdin=sub.PIPE)
response = list(command.communicate())
if len(response[1]) > 0:
raise Exception('Root Error')
except Exception as e:
if debug:
print(str(e))
return "Error"


def usb_on(debug=False):
"""
Shortcut for enable usb (need sudo).

:param debug: flag for using debug mode
:type debug:bool
:return: None
"""
usb_control("777", debug)


def usb_off(debug=False):
"""
Shortcut for disable usb (need sudo).

:param debug: flag for using debug mode
:type debug:bool
:return: None
"""
usb_control("000", debug)
3 changes: 2 additions & 1 deletion orangetool/orangetool_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def version():
:return: return orangetool-version number as string
"""
tprint("orangetool", font="bulbhead")
tprint("v"+ORANGETOOL_VERSION,font="bulbhead")
tprint("v" + ORANGETOOL_VERSION, font="bulbhead")


def wakeup(day=0, hour=0, minute=0, debug=False):
Expand Down Expand Up @@ -199,6 +199,7 @@ def sleep(debug=False):
"""
power_control("pm-suspend", debug)


def hibernate(debug=False):
"""
Shortcut for hibernate command (need sudo).
Expand Down