Last active
July 28, 2020 04:00
-
-
Save mitulp236/560b7933d2b28de193c24c88083e94a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from time import sleep | |
import sys | |
import os | |
try: | |
repository_name = str(sys.argv[1]) | |
except IndexError: | |
print("plase provide repository name as a argument") | |
exit() | |
github_username = "put your username" | |
github_password = "put your password" | |
driver = webdriver.Chrome("C:\\chromedriver.exe") | |
driver.get("https://github.com/login") | |
driver.find_element_by_xpath('//*[@id="login_field"]').send_keys(github_username) | |
driver.find_element_by_xpath('//*[@id="password"]').send_keys(github_password) | |
driver.find_element_by_xpath('//*[@id="login"]/form/div[4]/input[9]').click() | |
try: | |
print(driver.find_element_by_xpath('//*[@id="js-flash-container"]/div/div').text) | |
print("try again with correct username and password !") | |
print("Thank you__________!") | |
driver.quit() | |
exit() | |
except: | |
pass | |
driver.get("https://github.com/new") | |
driver.find_element_by_xpath('//*[@id="repository_name"]').send_keys(repository_name) | |
sleep(1) | |
if driver.find_element_by_xpath('/html/body/div[4]/main/div/form/div[2]/auto-check/dl/dd[2]').get_attribute("class") == 'error': | |
print('this repo is already exist ! try again with unique repo name') | |
print("Thank you__________!") | |
driver.quit() | |
exit() | |
# if you want to make your repo private then uncomment below line | |
# driver.find_element_by_xpath('//*[@id="repository_visibility_private"]').click() | |
# if you don't want to initialize your repo with README.MD then comment below line | |
driver.find_element_by_xpath('//*[@id="repository_auto_init"]').click() | |
driver.find_element_by_xpath('//*[@id="new_repository"]/div[4]/button').click() | |
# https://github.com/rockstart07/dwlijflw.git // clone this | |
executable_command = '"cd /d d:\myProjects\ & git clone https://github.com/{0}/{1}.git & cd {2} & code ."'.format(github_username,repository_name, repository_name) | |
os.system('cmd /c {0}'.format(executable_command)) | |
print("project created successfully !") | |
print("___________________Thank You____________________________________") | |
driver.quit() | |
# run : python Auto-project-setup.py project-name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment