Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on May 25, 2022. It is now read-only.

Commit 860ef56

Browse files
committed
fix for #134
1 parent fd13e61 commit 860ef56

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Script to shutdown and restart the system
2+
3+
- here the function is provided for both linux and windows.
4+
- please comment the section which is not applicable for you (linux or windows)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env python
2+
3+
import subprocess
4+
5+
6+
#### For windows ####
7+
def shutdown():
8+
instruction = "shutdown/s"
9+
try:
10+
output_response = subprocess.run(instruction, shell=True, capture_output=True)
11+
print(output_response)
12+
except Exception as e:
13+
print(e)
14+
15+
def restart():
16+
instruction = "shutdown/r"
17+
try:
18+
output_response = subprocess.run(instruction, shell=True, capture_output=True)
19+
print(output_response)
20+
except Exception as e:
21+
print(e)
22+
23+
"""
24+
###### For Linux ######
25+
def shutdown():
26+
instruction = "sudo shutdown -r now"
27+
try:
28+
output_response = subprocess.run(instruction, shell=True, capture_output=True)
29+
print(output_response)
30+
except Exception as e:
31+
print(e)
32+
33+
def restart():
34+
instruction = "shudo reboot"
35+
try:
36+
output_response = subprocess.run(instruction, shell=True, capture_output=True)
37+
print(output_response)
38+
except Exception as e:
39+
print(e)
40+
41+
"""
42+
if __name__=='__main__':
43+
option = input("Do you want to shutdown or restart [s/r]:")
44+
if option == 's':
45+
shutdown()
46+
elif option == 'r':
47+
restart()
48+
else:
49+
print("You want to continue using your pc! enjoy!")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /