remove not used functions

This commit is contained in:
Bela 2018-11-02 16:38:17 +01:00
parent 61d5361673
commit aed1fccc6f

View file

@ -70,15 +70,6 @@ def checkLinkAccess(dir):
return True
def isTypicalPath(dir):
"""Check if dir is a directory that is typically a path directory."""
if dir.startswith(os.path.join("/", "usr")) and dir.endswith("bin"):
return True
if dir.startswith(os.path.join("/", "bin")):
return True
return False
def defaultPath():
"""Choose a suitable default directory for installing.
@ -131,84 +122,6 @@ def defaultPath():
raise FileNotFoundError("No directory for installation found.")
def askUserForPath():
"""Ask user where to install.
List all accessible directories in the path and ask which
one should be used.
Suggest a typical one.
Also list directories without permission with information
to start install script via sudo.
"""
path = getPath()
typicalPaths = [os.path.join("/", "usr", "local", "bin"),
os.path.join("/", "usr", "bin"),
os.path.join("/", "bin"),
os.path.join(os.environ.get("HOME", ""), ".bin"),
os.path.join(os.environ.get("HOME", ""), "bin")]
# typical directories that are not in the path are useless
typicalPaths = [directory for directory in typicalPaths if
directory in path]
print("typicalPaths:", typicalPaths)
accessiblePaths = [directory for directory in path if
os.access(directory, os.R_OK) and
os.access(directory, os.W_OK) and
os.access(directory, os.X_OK)]
print("accessiblePaths:", accessiblePaths)
# I want to have all rights
# such that nothing can go wrong
typicalAccessiblePaths = [directory for directory in typicalPaths if
directory in accessiblePaths]
print("typicalAccessiblePaths:", typicalAccessiblePaths)
untypicalAccessiblePaths = [directory for directory in accessiblePaths if
directory not in typicalPaths]
print("untypicalAccessiblePaths:", untypicalAccessiblePaths)
unaccessiblePaths = [directory for directory in path if
directory not in accessiblePaths]
print("unaccessiblePaths:", unaccessiblePaths)
print("""Choose the directory for the installation.""")
optioncounter = 0
untypicalTitle = "Those are also possible:"
if len(typicalAccessiblePaths) > 0:
print("I suggest one of the following:")
untypicalTitle = "Those are possible:"
for directory in typicalAccessiblePaths:
optioncounter = optioncounter + 1
print(str(optioncounter) + ") " + directory)
if len(untypicalAccessiblePaths) > 0:
print(untypicalTitle)
for directory in untypicalAccessiblePaths:
optioncounter = optioncounter + 1
print(str(optioncounter) + ") " + directory)
if len(unaccessiblePaths) > 0:
print("Those you cannot access. If you want to use one of them,\n" +
"abort this script (Ctrl/Strg + c)" +
"and start it with root access (sudo):""")
for directory in unaccessiblePaths:
print(directory)
try:
userinput = int(input("Type a number from 1 to "
+ str(optioncounter) + ": "))
except KeyboardInterrupt as e:
print("Input aborted. Abort program.")
raise
except EOFError as e:
print("Input aborted. Abort program.")
raise
except ValueError as e:
print("Invalid input. Really, it is not hard!")
raise
if userinput <= len(typicalAccessiblePaths):
return typicalAccessiblePaths[userinput - 1]
else:
try:
return untypicalAccessiblePaths[
userinput - len(typicalAccessiblePaths) - 1]
except IndexError as e:
print("Invalid input. Really, it is not hard!")
def createProgramSymlinks(where):
"""Create symlinks to some of scripts in this project.