Repository navigation
Expand file tree
/
Copy pathcreate_git_rep.py
More file actions
54 lines (40 loc) · 1.71 KB
/
Copy pathcreate_git_rep.py
File metadata and controls
54 lines (40 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import sys
import os
from selenium import webdriver
"""
Uses selenium to create a git repository in github.com using chrome
"""
path = "/Users/maximilianvorbrodt/Documents/PROGRAMMING/GitRepositories/"
chromedriver = "/Users/maximilianvorbrodt/Downloads/chromedriver"
browser = webdriver.Chrome(chromedriver)
browser.get('https://github.com/login')
def create():
#take in argument from bash and make directory
folderName = str(sys.argv[1])
os.makedirs(path + folderName)
print (path + folderName)
#create python button and use it to login
#Right click on item then select inspect, copy XPath
python_button = browser.find_elements_by_xpath("//input[@name='login']")[0]
python_button.send_keys('vorbrodt')
python_button = browser.find_elements_by_xpath("//*[@id='password']")[0]
python_button.send_keys('password')
python_button = browser.find_elements_by_xpath("//*[@id='login']/form/div[4]/input[9]")[0]
python_button.click()
#go to create new repository
browser.get('https://github.com/new')
#add repository name
python_button = browser.find_elements_by_xpath("//*[@id='repository_name']")[0]
python_button.send_keys(folderName)
#make git repository private
python_button = browser.find_elements_by_xpath("//*[@id='repository_visibility_private']")[0]
python_button.click()
#initialize this repository with a README
#python_button = browser.find_elements_by_xpath("//*[@id='repository_auto_init']")[0]
#python_button.click()
#press "Create repository" button via css selector
python_button = browser.find_element_by_css_selector('button.first-in-line')
python_button.submit()
browser.quit()
if __name__ == "__main__":
create()