From b931a54109d0af73a85691b24681727a88e882d8 Mon Sep 17 00:00:00 2001 From: Aziz Fikri <45133910+afikrim@users.noreply.github.com> Date: Wed, 8 Jan 2020 23:55:40 +0700 Subject: [PATCH 1/5] Update remove.py --- remove.py | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/remove.py b/remove.py index 6780127..fede490 100644 --- a/remove.py +++ b/remove.py @@ -1,26 +1,19 @@ import sys -from selenium import webdriver - -username = sys.argv[1] -password = sys.argv[2] -reponame = sys.argv[3] - -browser = webdriver.Chrome() -browser.get('http://github.com/login') +import getpass +from github import Github +reponame = sys.argv[1] def remove(): - browser.find_elements_by_xpath("//input[@name='login']")[0].send_keys(username) - browser.find_elements_by_xpath("//input[@name='password']")[0].send_keys(password) - browser.find_elements_by_xpath("//input[@name='commit']")[0].click() - browser.get('https://github.com/silv4b/' + reponame + '/settings') - browser.find_elements_by_xpath('//*[@id="options_bucket"]/div[9]/ul/li[4]/details/summary')[0].click() - browser.find_elements_by_xpath( - '//*[@id="options_bucket"]/div[9]/ul/li[4]/details/details-dialog/div[3]/form/p/input')[0].send_keys(reponame) - browser.find_elements_by_xpath( - '//*[@id="options_bucket"]/div[9]/ul/li[4]/details/details-dialog/div[3]/form/button')[0].click() - browser.get("https://github.com/" + username) - + username = raw_input("Username for 'www.github.com': ") + password = getpass.getpass("Password for '" + username + "@github.com': ") + user = Github(username, password) + try: + repo = user.get_repo(username + "/" + reponame) + repo.delete() + print("Repository deleted.") + except: + print("No repo found!") if __name__ == "__main__": remove() From 80ad20ada82462f19d28bbcf65a1cd45dfdb6f47 Mon Sep 17 00:00:00 2001 From: Aziz Fikri <45133910+afikrim@users.noreply.github.com> Date: Thu, 9 Jan 2020 00:05:52 +0700 Subject: [PATCH 2/5] Update .my_commands.sh --- .my_commands.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.my_commands.sh b/.my_commands.sh index a99f9c2..88c91b3 100644 --- a/.my_commands.sh +++ b/.my_commands.sh @@ -3,12 +3,22 @@ function create() { cd python create.py $1 - cd /Users/kalle/Documents/Projects/MyProjects/$1 + cd ~/Documents/Projects/MyProjects/$1 git init - git remote add origin git@github.com:KalleHallden/$1.git + git remote add origin git@github.com:$2/$1.git touch README.md git add . git commit -m "Initial commit" git push -u origin master code . -} \ No newline at end of file +} + +function remove() { + cd ~/Documents/Projects/MyProjects + read -p "Are you sure?[y/n]" confirm + if [ "$confirm" = "n" ] || [ "$confirm" = "N" ]; then + return + fi + rm -rf $1 + python remove.py $1 +} From 88320c1a601009e59ee4c6e83cc57eacfe85880a Mon Sep 17 00:00:00 2001 From: Aziz Fikri <45133910+afikrim@users.noreply.github.com> Date: Thu, 9 Jan 2020 00:12:30 +0700 Subject: [PATCH 3/5] Update create.py --- create.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/create.py b/create.py index e459fb9..beb6ab4 100644 --- a/create.py +++ b/create.py @@ -1,16 +1,25 @@ import sys import os +import getpass from github import Github -path = "/Users/kalle/Documents/Projects/MyProjects/" - -username = "" #Insert your github username here -password = "" #Insert your github password here +path = "~/Documents/Projects/MyProjects/" def create(): folderName = str(sys.argv[1]) - os.makedirs(path + str(folderName) - user = Github(username, password).get_user() + os.makedirs(path + str(folderName)) + isLogedIn = False + + while not isLogedIn: + username = raw_input("Username for 'www.github.com': ") + password = getpass.getpass("Password for '" + username + "@github.com': ") + user = Github(username, password).get_user() + try: + user.login + isLoggedIn = True + except: + print("Credentials are wrong.") + repo = user.create_repo(folderName) print("Succesfully created repository {}".format(folderName)) From 097f53c8313935c679a8789c58c4ba718433f00f Mon Sep 17 00:00:00 2001 From: Aziz Fikri <45133910+afikrim@users.noreply.github.com> Date: Thu, 9 Jan 2020 00:14:49 +0700 Subject: [PATCH 4/5] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dad267e..a0bcc1c 100644 --- a/README.md +++ b/README.md @@ -10,5 +10,6 @@ Also make sure to change all directories to your directories so it should be '/U ### Usage: ```bash -To run the script type in 'create ' +To create project type in 'create ' +To remove project type in 'remove ' ``` From 38c5f56a5a7a211ea988150f820403523fffbf19 Mon Sep 17 00:00:00 2001 From: Aziz Fikri <45133910+afikrim@users.noreply.github.com> Date: Thu, 9 Jan 2020 00:19:02 +0700 Subject: [PATCH 5/5] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a0bcc1c..86e1bfd 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ git clone "https://github.com/KalleHallden/ProjectInitializationAutomation.git" cd ProjectInitializationAutomation pip install -r requirements.txt source ~/.my_commands.sh -Then go to create.py and set the username and password to be your username and password. -Also make sure to change all directories to your directories so it should be '/Users//path/to/your/project' + +# if you're using linux, you can add source ~/.my_commands.sh to your ~/.bashrc, so you dont have to type that every time you open the terminal ``` ### Usage: