Skip to content

Commit

Permalink
remove script to be main condition - not required
Browse files Browse the repository at this point in the history
  • Loading branch information
rhl-bthr committed Sep 14, 2018
1 parent 4ac5693 commit 79a8073
Showing 1 changed file with 34 additions and 39 deletions.
73 changes: 34 additions & 39 deletions src/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,54 +11,49 @@
INSTALL_PATH = join(os.path.expanduser("~"), ".nalanda-cli")
session = requests.session()

FOLDER_LIST = ["News", "Notices", "Lectures", "Subjects"]

try:
while True:
email = input("\nEnter BITS ID [Eg: f2016015]\n")
email += "@pilani.bits-pilani.ac.in"

if __name__ == "__main__":
try:
for folder_name in FOLDER_LIST:
os.makedirs(join(INSTALL_PATH, folder_name))

while True:
email = input("\nEnter BITS ID [Eg: f2016015]\n")
email += "@pilani.bits-pilani.ac.in"
password = getpass(prompt = "Enter nalanda password:")

password = getpass(prompt = "Enter nalanda password:")
with open(join(INSTALL_PATH, "config.txt"), "w") as f:
config = email + "\n" + password
f.write(config)

with open(join(INSTALL_PATH, "config.txt"), "w") as f:
config = email + "\n" + password
f.write(config)
result = session.post(
"http://nalanda.bits-pilani.ac.in/login/index.php",
data={
"username": email,
"password": password,
})
result = BeautifulSoup(result.text, "html.parser")

result = session.post(
"http://nalanda.bits-pilani.ac.in/login/index.php",
data={
"username": email,
"password": password,
})
result = BeautifulSoup(result.text, "html.parser")
if not result.find_all("a", {"id": "loginerrormessage"}):
break
print("Username or Password Incorrect. Please retry")

if not result.find_all("a", {"id": "loginerrormessage"}):
break
print("Username or Password Incorrect. Please retry")

with open(join(INSTALL_PATH, "sub-url.txt"), "w") as url_file:
with open(join(INSTALL_PATH, "sub-name.txt"), "w") as name_file:
with open(join(INSTALL_PATH, "sub-url.txt"), "w") as url_file:
with open(join(INSTALL_PATH, "sub-name.txt"), "w") as name_file:

result = session.get("http://nalanda.bits-pilani.ac.in/my")
soup = BeautifulSoup(result.text, "html.parser")
result = session.get("http://nalanda.bits-pilani.ac.in/my")
soup = BeautifulSoup(result.text, "html.parser")

sub_url, sub_name = [], []
sub_url, sub_name = [], []

for x in soup.find_all("div", "column c1"):
sub_url.append(x.contents[0].get("href"))
sub_name.append(((x.contents[0].contents[1]).split("/")[0]).split("\\")[0])
for x in soup.find_all("div", "column c1"):
sub_url.append(x.contents[0].get("href"))
sub_name.append(((x.contents[0].contents[1]).split("/")[0]).split("\\")[0])

url_file.write("\n".join(sub_url))
name_file.write("\n".join(sub_name))
url_file.write("\n".join(sub_url))
name_file.write("\n".join(sub_name))

except KeyboardInterrupt:
quit("Installation cancelled by user. Please retry.")
except requests.exceptions.ConnectionError:
quit("No Internet Connection. Please retry.")
except IOError:
quit("Unable to read from file. Please reinstall nalanda-cli.")
except KeyboardInterrupt:
quit("Installation cancelled by user. Please retry.")
except requests.exceptions.ConnectionError:
quit("No Internet Connection. Please retry.")
except IOError:
quit("Unable to read from file. Please reinstall nalanda-cli.")

0 comments on commit 79a8073

Please sign in to comment.