-
Notifications
You must be signed in to change notification settings - Fork 0
/
create.py
48 lines (37 loc) · 1.51 KB
/
create.py
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
import os
import json
from github import Github
from search import project
def createRepo(project):
path = project[0]
folder = project[1]
with open('./config/config.json') as config:
data = json.load(config)
token = data['git_token'] # Enter your access token
g = Github(token)
user = g.get_user()
login = user.login
repo = user.create_repo(folder)
link = f'https://github.com/{login}/{folder}.git'
fileLink = open("link.txt", "w")
fileLink.write(link)
fileLink.close()
for i in project:
try:
os.chdir(path)
f = open(".gitignore", "w+") # Create the gitignore file
f.write("complete.txt") # Add the complete.txt file to the gitignore file
f.close() # Close and save the changes to the file.
os.system('git init')
os.system('git add .')
os.system(f'git remote add origin {link}')
os.system('git commit -m "Initial commit made by Push2Hub"')
os.system('git push -u origin master')
project.remove(path) # Remove the file path
project.remove(folder) # Remove teh folder name
# print(project)
os.remove("complete.txt") # Remove the complete.txt file from the directory
except OSError as e:
print(f"Unable to created {folder} project")
print(f'Error:\n{e}')
config.close()