Skip to content
Open
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
16 changes: 13 additions & 3 deletions .my_commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
}
}

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
}
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ 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/<your username>/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:
```bash
To run the script type in 'create <name of your folder>'
To create project type in 'create <name of your folder>'
To remove project type in 'remove <name of your folder>'
```
21 changes: 15 additions & 6 deletions create.py
Original file line number Diff line number Diff line change
@@ -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))

Expand Down
31 changes: 12 additions & 19 deletions remove.py
Original file line number Diff line number Diff line change
@@ -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()