Skip to content
Closed
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
2 changes: 2 additions & 0 deletions DIRECTORY.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -233,6 +233,7 @@
* [Merge Two Lists](data_structures/linked_list/merge_two_lists.py)
* [Middle Element Of Linked List](data_structures/linked_list/middle_element_of_linked_list.py)
* [Print Reverse](data_structures/linked_list/print_reverse.py)
* [Reverse K Group](data_structures/linked_list/reverse_k_group.py)
* [Rotate To The Right](data_structures/linked_list/rotate_to_the_right.py)
* [Singly Linked List](data_structures/linked_list/singly_linked_list.py)
* [Skip List](data_structures/linked_list/skip_list.py)
Expand DownExpand Up@@ -727,6 +728,7 @@
## Other
* [Activity Selection](other/activity_selection.py)
* [Alternative List Arrange](other/alternative_list_arrange.py)
* [Check Net Share](other/check_net_share.py)
* [Davisb Putnamb Logemannb Loveland](other/davisb_putnamb_logemannb_loveland.py)
* [Dijkstra Bankers Algorithm](other/dijkstra_bankers_algorithm.py)
* [Doomsday](other/doomsday.py)
Expand Down
40 changes: 40 additions & 0 deletions other/check_net_share.py
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
import os

path = '\\examplepc\smb'

#check if network path available and user has rights to access it
def check_share(path:str)->bool:
if os.path.exists(path):
err = 1
return True
else:
err = 0
return False

#check if user has rights for network path
def check_rights(path:str)->bool:
try:
os.listdir(path)
return True
except:
i = 2
return False

#return error to stdout if i <> 1
def check_share_error(i:int):
if i == 0:
print("Network path not available")
elif i == 2:
print("User has no rights to access network path")
else:
print("Network path available and user has rights to access it")

#first check if share exist, then check if user has rights to access it
def check_share_rights(path:str):
if check_share(path) is True:
check_share_error(check_rights(path))
else:
check_share_error(0)

#call function
check_share_rights(path)