Skip to content

Commit

Permalink
Mostly bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
80sVectorz committed Feb 8, 2022
1 parent 1d887a2 commit 9592971
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
25 changes: 15 additions & 10 deletions portal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,23 @@ elif [ "$arg1" = "-r" ]; then
elif [ "$arg1" = "--remove" ]; then
remove_portal "$2"
elif [ "$arg1" = "to" ]; then
python /bin/portal_bin/portalCONFIG.py "-r" "flavor_messages"
if [ $? -eq 0 ]; then
echo "Entering portal..."
fi
pythonOut=$(python /bin/portal_bin/portalDB.py -R $2)
if [ $? -eq 2 ]; then
echo "Portal $2 does not exist."
if [ -z "$2" ]; then
echo "Failed to portal: missing arguments."
else
if [ $? -eq 2 ]; then
echo "Directory after portal $2 does not exist."
python /bin/portal_bin/portalCONFIG.py "-r" "flavor_messages"
if [ $? -eq 0 ]; then
echo "Entering portal..."
fi
pythonOut=$(python /bin/portal_bin/portalDB.py -R $2)
if [ $? -eq 1 ]; then
echo "Portal $2 does not exist."
else
cd ${pythonOut}
python /bin/portal_bin/portalDB.py "-R" "$2"
if [ $? -eq 2 ]; then
echo "Directory after portal $2 does not exist."
else
cd ${pythonOut}
fi
fi
fi
elif [ "$arg1" = "-c" ]; then
Expand Down
3 changes: 3 additions & 0 deletions portalCONFIG.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

config = {"flavor_messages": True}

if not os.path.exists(str(Path.home())+"/.config/portal_config"):
os.mkdir(str(Path.home())+"/.config/portal_config")

if not os.path.exists(str(Path.home())+"/.config/portal_config/config.pickle"):
pickle.dump(config,open(str(Path.home())+"/.config/portal_config/config.pickle","wb"))
else:
Expand Down
7 changes: 5 additions & 2 deletions portalDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@
if sys.argv[2].split("/")[0] in portals.keys():
sys.exit(1)
else:
sys.exit(2)
sys.exit(1)
elif sys.argv[1] == "-W":
portals[sys.argv[2]] = sys.argv[3]
pickle.dump(portals,open(str(Path.home())+"/.config/portal_config/portals.pickle","wb"))
elif sys.argv[1] == "-R":
if sys.argv[2].split("/")[0] in portals.keys():
if os.path.exists(portals[sys.argv[2].split("/")[0]]+"/"+"/".join(sys.argv[2].split("/")[1:])):
if sys.argv[2].count("/")>0 and os.path.exists(portals[sys.argv[2].split("/")[0]]+"/"+("/".join(sys.argv[2].split("/")[1:]))):
print(portals[sys.argv[2].split("/")[0]]+"/"+"/".join(sys.argv[2].split("/")[1:]))
sys.exit(0)
elif sys.argv[2].count("/") == 0:
print(portals[sys.argv[2].split("/")[0]])
sys.exit(0)
else:
sys.exit(2)
else:
Expand Down

0 comments on commit 9592971

Please sign in to comment.