Fixed and Added.
This commit is contained in:
parent
32e304e8ad
commit
6d8d5d8c8a
158
.idea/workspace.xml
generated
158
.idea/workspace.xml
generated
@ -2,15 +2,10 @@
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="d703f139-38f3-455d-a086-a2da561870b5" name="Default Changelist" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/.idea/encodings.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/keygen.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/giteasy.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/giteasy.iml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/window.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/bin/python" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/bin/python3" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/server.py" beforeDir="false" afterPath="$PROJECT_DIR$/server.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ssh.py" beforeDir="false" afterPath="$PROJECT_DIR$/ssh.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/git.py" beforeDir="false" afterPath="$PROJECT_DIR$/git.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/keygen.py" beforeDir="false" afterPath="$PROJECT_DIR$/keygen.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@ -20,7 +15,9 @@
|
||||
</component>
|
||||
<component name="CoverageDataManager">
|
||||
<SUITE FILE_PATH="coverage/giteasy$ssh.coverage" NAME="ssh Coverage Results" MODIFIED="1552191792390" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
||||
<SUITE FILE_PATH="coverage/giteasy$Debug.coverage" NAME="Debug Coverage Results" MODIFIED="1552274220071" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
||||
<SUITE FILE_PATH="coverage/giteasy$window.coverage" NAME="window Coverage Results" MODIFIED="1552301739669" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
||||
<SUITE FILE_PATH="coverage/giteasy$keygen.coverage" NAME="keygen Coverage Results" MODIFIED="1552276631897" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
||||
<SUITE FILE_PATH="coverage/giteasy$Debug.coverage" NAME="Debug Coverage Results" MODIFIED="1552275762807" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="DatabaseView">
|
||||
<option name="SHOW_INTERMEDIATE" value="true" />
|
||||
@ -39,10 +36,10 @@
|
||||
<component name="FileEditorManager">
|
||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/server.py">
|
||||
<entry file="file://$PROJECT_DIR$/git.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="436">
|
||||
<caret line="191" column="58" selection-start-line="191" selection-start-column="58" selection-end-line="191" selection-end-column="58" />
|
||||
<state relative-caret-position="354">
|
||||
<caret line="165" column="14" lean-forward="true" selection-start-line="165" selection-start-column="14" selection-end-line="165" selection-end-column="14" />
|
||||
<folding>
|
||||
<element signature="e#1#10#0" expanded="true" />
|
||||
</folding>
|
||||
@ -53,8 +50,8 @@
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/ssh.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="875">
|
||||
<caret line="35" column="13" lean-forward="true" selection-start-line="35" selection-start-column="13" selection-end-line="35" selection-end-column="13" />
|
||||
<state relative-caret-position="150">
|
||||
<caret line="6" column="18" selection-start-line="6" selection-start-column="18" selection-end-line="6" selection-end-column="18" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -62,8 +59,8 @@
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/keygen.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="300">
|
||||
<caret line="12" lean-forward="true" selection-start-line="12" selection-end-line="12" />
|
||||
<state relative-caret-position="325">
|
||||
<caret line="13" column="64" lean-forward="true" selection-start-line="13" selection-start-column="64" selection-end-line="13" selection-end-column="64" />
|
||||
<folding>
|
||||
<element signature="e#0#13#0" expanded="true" />
|
||||
</folding>
|
||||
@ -71,6 +68,21 @@
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/window.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="654">
|
||||
<caret line="158" lean-forward="true" selection-start-line="158" selection-end-line="158" />
|
||||
<folding>
|
||||
<element signature="e#0#21#0" expanded="true" />
|
||||
<element signature="e#92#237#0" />
|
||||
<element signature="e#1052#1235#0" />
|
||||
<element signature="e#1318#1405#0" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
@ -95,8 +107,10 @@
|
||||
<option value="$PROJECT_DIR$/lib/ssh.py" />
|
||||
<option value="$PROJECT_DIR$/venv/ssh.py" />
|
||||
<option value="$PROJECT_DIR$/ssh.py" />
|
||||
<option value="$PROJECT_DIR$/keygen.py" />
|
||||
<option value="$PROJECT_DIR$/server.py" />
|
||||
<option value="$PROJECT_DIR$/keygen.py" />
|
||||
<option value="$PROJECT_DIR$/window.py" />
|
||||
<option value="$PROJECT_DIR$/git.py" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
@ -154,7 +168,7 @@
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<component name="RunManager" selected="Python.window">
|
||||
<configuration name="Debug" type="PythonConfigurationType" factoryName="Python">
|
||||
<module name="giteasy" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
@ -199,6 +213,61 @@
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="keygen" type="PythonConfigurationType" factoryName="Python" temporary="true">
|
||||
<module name="giteasy" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="$PROJECT_DIR$/bin/python" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/keygen.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="window" type="PythonConfigurationType" factoryName="Python" temporary="true">
|
||||
<module name="giteasy" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="$PROJECT_DIR$/bin/python" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/window.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<list>
|
||||
<item itemvalue="Python.Debug" />
|
||||
<item itemvalue="Python.keygen" />
|
||||
<item itemvalue="Python.window" />
|
||||
</list>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Python.window" />
|
||||
<item itemvalue="Python.keygen" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
<component name="SvnConfiguration">
|
||||
<configuration />
|
||||
@ -210,12 +279,20 @@
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1552027430305</updated>
|
||||
<workItem from="1552263509381" duration="3100000" />
|
||||
<workItem from="1552263509381" duration="21133000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Fixed and Added.">
|
||||
<created>1552274282898</created>
|
||||
<option name="number" value="00001" />
|
||||
<option name="presentableId" value="LOCAL-00001" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1552274282898</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="2" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="3100000" />
|
||||
<option name="totallyTimeSpent" value="21133000" />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
|
||||
@ -247,6 +324,10 @@
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="1" />
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="Fixed and Added." />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Fixed and Added." />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
<default-breakpoints>
|
||||
@ -259,27 +340,40 @@
|
||||
</breakpoint-manager>
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/ssh.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="875">
|
||||
<caret line="35" column="13" lean-forward="true" selection-start-line="35" selection-start-column="13" selection-end-line="35" selection-end-column="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/keygen.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="300">
|
||||
<caret line="12" lean-forward="true" selection-start-line="12" selection-end-line="12" />
|
||||
<state relative-caret-position="325">
|
||||
<caret line="13" column="64" lean-forward="true" selection-start-line="13" selection-start-column="64" selection-end-line="13" selection-end-column="64" />
|
||||
<folding>
|
||||
<element signature="e#0#13#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/server.py">
|
||||
<entry file="file://$PROJECT_DIR$/ssh.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="436">
|
||||
<caret line="191" column="58" selection-start-line="191" selection-start-column="58" selection-end-line="191" selection-end-column="58" />
|
||||
<state relative-caret-position="150">
|
||||
<caret line="6" column="18" selection-start-line="6" selection-start-column="18" selection-end-line="6" selection-end-column="18" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/window.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="654">
|
||||
<caret line="158" lean-forward="true" selection-start-line="158" selection-end-line="158" />
|
||||
<folding>
|
||||
<element signature="e#0#21#0" expanded="true" />
|
||||
<element signature="e#92#237#0" />
|
||||
<element signature="e#1052#1235#0" />
|
||||
<element signature="e#1318#1405#0" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/git.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="354">
|
||||
<caret line="165" column="14" lean-forward="true" selection-start-line="165" selection-start-column="14" selection-end-line="165" selection-end-column="14" />
|
||||
<folding>
|
||||
<element signature="e#1#10#0" expanded="true" />
|
||||
</folding>
|
||||
|
77
git.py
77
git.py
@ -41,7 +41,7 @@ class Git(ssh.SSH):
|
||||
print("Create directory.")
|
||||
else:
|
||||
raise ValueError(stderr)
|
||||
self.base_path = [True, "{0}/{1}".format(self.path, "giteasy")]
|
||||
self.base_path = [True, "{0}{1}".format(self.path, "giteasy")]
|
||||
else:
|
||||
raise ValueError("Home Path Abnormal")
|
||||
|
||||
@ -67,14 +67,28 @@ class Git(ssh.SSH):
|
||||
else:
|
||||
raise UnboundLocalError("Init Base First")
|
||||
|
||||
def clone_project(self):
|
||||
os.chdir(self.local_path)
|
||||
os.popen("git clone ssh://{0}@{1}:{2}/{3}/.git".format(self.user, self.hostname, self.base_path[1],
|
||||
self.fix_name))
|
||||
|
||||
def init_project_local(self, name):
|
||||
cmd = self.fix_cmd
|
||||
cmd += "mkdir {0};".format(name)
|
||||
cmd += "git init;"
|
||||
cmd = "git config --global user.email \"{0}\";".format(self.git_email)
|
||||
cmd += "git config --global user.name \"{0}\";".format(self.git_user)
|
||||
os.chdir(self.local_path)
|
||||
try:
|
||||
os.mkdir(name)
|
||||
except FileExistsError:
|
||||
os.chdir(os.path.join(self.local_path, name))
|
||||
raise FileExistsError("Project Already Exist.")
|
||||
os.chdir(os.path.join(self.local_path, name))
|
||||
cmd = "git init"
|
||||
os.popen(cmd)
|
||||
|
||||
def global_init_local(self):
|
||||
cmd = "git config --global user.email \"{0}\"".format(self.git_email)
|
||||
print(os.popen(cmd).read())
|
||||
cmd = "git config --global user.name \"{0}\"".format(self.git_user)
|
||||
print(os.popen(cmd).read())
|
||||
|
||||
def update_projects(self):
|
||||
if self.base_path[0]:
|
||||
stdout, stderr = self.run("ls {0}".format(self.base_path[1]))
|
||||
@ -104,9 +118,8 @@ class Git(ssh.SSH):
|
||||
os.chdir(self.local_path)
|
||||
|
||||
def add_remote(self, name="origin"):
|
||||
os.popen(
|
||||
"git remote add {3} ssh://{0}@{1}:{2}/{4}/.git".format(self.user, self.hostname, self.base_path[1], name,
|
||||
self.fix_name))
|
||||
os.popen("git remote add {3} ssh://{0}@{1}:{2}/{4}/.git".format(self.user, self.hostname, self.base_path[1],
|
||||
name, self.fix_name))
|
||||
self.remotes[name] = {"name": name,
|
||||
"url": "ssh://{0}@{1}:{2}/{3}/.git".format(self.user, self.hostname, self.base_path[1],
|
||||
self.fix_name)}
|
||||
@ -119,11 +132,16 @@ class Git(ssh.SSH):
|
||||
ret_code = re.compile(r"[\t, ]")
|
||||
for remote in os.popen("git remote -v").readlines():
|
||||
results = ret_code.split(remote)
|
||||
for item in results:
|
||||
if item[0] not in self.remotes.keys():
|
||||
self.remotes[item[0]] = {"name": item[0], "url": item[1]}
|
||||
print(results)
|
||||
results = list(results)
|
||||
if len(results) > 1:
|
||||
for item in results:
|
||||
if item[0] not in self.remotes.keys():
|
||||
self.remotes[results[0]] = {"name": results[0], "url": results[1]}
|
||||
|
||||
def push_remote(self, name, branch):
|
||||
print(self.projects[self.fix_name]["branch"])
|
||||
print(self.projects[self.fix_name])
|
||||
if branch in self.projects[self.fix_name]["branch"] and name in self.remotes.keys():
|
||||
os.popen("git push {0} {1}".format(name, branch))
|
||||
else:
|
||||
@ -135,13 +153,13 @@ class Git(ssh.SSH):
|
||||
else:
|
||||
raise ValueError("Remote Error")
|
||||
|
||||
def fix(self, name):
|
||||
def fix_project(self, name):
|
||||
if name in self.projects_list:
|
||||
self.fix_name = name
|
||||
stdout, stderr = self.run("cd {0}".format(self.projects[name]["path"]))
|
||||
if self.check_error(stderr):
|
||||
print("Fixed.")
|
||||
self.fix_cmd = "cd {0}".format(self.projects[name]["path"]) + ";"
|
||||
os.chdir(os.path.join(self.local_path, self.fix_name))
|
||||
else:
|
||||
raise ValueError("Project Path Abnormal")
|
||||
|
||||
@ -155,10 +173,21 @@ class Git(ssh.SSH):
|
||||
else:
|
||||
raise UnboundLocalError("Init Base First")
|
||||
|
||||
def commit_local(self, message):
|
||||
if self.base_path[0]:
|
||||
os.popen("git commit --message={0}".format(message))
|
||||
else:
|
||||
raise UnboundLocalError("Init Base First")
|
||||
|
||||
@staticmethod
|
||||
def add():
|
||||
os.popen("git add *")
|
||||
|
||||
def get_branch(self):
|
||||
if self.base_path[0] and self.fix_name is None:
|
||||
if self.base_path[0] and self.fix_name is not None:
|
||||
stdout, stderr = self.run(self.fix_cmd + "git branch")
|
||||
if self.check_error(stderr):
|
||||
self.projects[self.fix_name]["branch"] = []
|
||||
reform = re.compile("\w+")
|
||||
for branch in stdout:
|
||||
branch_name = reform.search("*master").group().strip('\n')
|
||||
@ -182,17 +211,15 @@ class Git(ssh.SSH):
|
||||
if __name__ == "__main__":
|
||||
compute = Git("compute.bktus.com", "/home/git", "git", "123456")
|
||||
compute.global_init(git_user="saturneric", git_email="eric.bktu@gmail.com")
|
||||
compute.global_init_local()
|
||||
compute.base_init()
|
||||
# compute.create_project("lcs")
|
||||
compute.update_projects()
|
||||
compute.list_projects()
|
||||
compute.fix("lcs")
|
||||
|
||||
# compute.get_branch("lcs")
|
||||
compute.set_local("C:/Users/Saturneric/Documents/Code/")
|
||||
compute.init_project_local("test")
|
||||
# compute.add_remote();
|
||||
# compute.get_remote()
|
||||
# compute.get_branch()
|
||||
# compute.list_branch()
|
||||
print(compute.projects)
|
||||
compute.fix_project("lcs")
|
||||
compute.get_branch()
|
||||
compute.set_local("C:\\Users\\Saturneric\\Documents\\Code\\")
|
||||
# compute.init_project_local("test")
|
||||
compute.add_remote()
|
||||
compute.get_remote()
|
||||
compute.list_branch()
|
||||
|
20
keygen.py
20
keygen.py
@ -10,22 +10,26 @@ class Key(ssh.SSH):
|
||||
self.connect(5)
|
||||
self.pub_key = None
|
||||
self.keygen = None
|
||||
self.local_path = "C:\\Users\\Saturneric\\"
|
||||
self.public_key_path = self.local_path+".ssh/id_rsa.pub"
|
||||
self.public_key = None
|
||||
|
||||
def add_key(self):
|
||||
self.run("echo \"{0}\" >> ~/.ssh/authorized_keys".format(self.pub_key))
|
||||
self.run("echo \"{0}\" >> ~/.ssh/authorized_keys".format(self.public_key))
|
||||
|
||||
def create_key(self):
|
||||
ret_code = subprocess.Popen(["ssh-keygen", "-b 4096", "-t rsa"], shell=True,
|
||||
@staticmethod
|
||||
def create_key():
|
||||
ret_code = subprocess.Popen(["ssh-keygen", "-b 4096"], shell=True,
|
||||
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
stdout, stderr = ret_code.communicate(input=b"\ny \n \n \n")
|
||||
self.get_key()
|
||||
stdout, stderr = ret_code.communicate(input=b"\n \n \n \n")
|
||||
|
||||
def get_key(self):
|
||||
self.pub_key = os.popen("cat ~/.ssh/id_rsa.pub").read()
|
||||
self.public_key = open(self.public_key_path, 'r').readline()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
new_key = Key("compute.bktus.com", "/home/git", "git", "123456", ssh_key=False)
|
||||
# new_key.create_key()
|
||||
# new_key.get_key()
|
||||
# new_key.add_key()
|
||||
new_key.get_key()
|
||||
print(new_key.public_key)
|
||||
new_key.add_key()
|
||||
|
270
window.py
Normal file
270
window.py
Normal file
@ -0,0 +1,270 @@
|
||||
from tkinter import *
|
||||
import git
|
||||
|
||||
|
||||
class Window(Frame):
|
||||
def __init__(self, master = None):
|
||||
Frame.__init__(self, master)
|
||||
self.master = master
|
||||
self.master = master
|
||||
self.pack()
|
||||
self.width = 800
|
||||
self.height = 600
|
||||
self.position = [10, 10]
|
||||
|
||||
def set_width(self, width):
|
||||
self.width = width
|
||||
|
||||
def set_height(self, height):
|
||||
self.height = height
|
||||
|
||||
def set_position(self, x=10, y=10):
|
||||
self.position = [x, y]
|
||||
|
||||
def apply(self):
|
||||
self.master.geometry("{0}x{1}+{2}+{3}".format(self.width, self.height, self.position[0], self.position[1]))
|
||||
|
||||
|
||||
class Info(Window):
|
||||
def __init__(self, master=None):
|
||||
super().__init__(master)
|
||||
self.information_label = Label(self)
|
||||
self.information = Entry(self)
|
||||
self.ok = Button(self)
|
||||
self.draw_widgets()
|
||||
|
||||
def draw_widgets(self):
|
||||
self.information_label["text"] = "Info: "
|
||||
self.information_label.grid(row=0, column=0)
|
||||
self.information.grid(row=0, column=1)
|
||||
self.ok["text"] = "OK"
|
||||
self.ok.grid(row=0, column=2)
|
||||
|
||||
def set_click(self, func):
|
||||
self.ok["command"] = func
|
||||
|
||||
|
||||
class Main(Window):
|
||||
def __init__(self, master=None):
|
||||
super().__init__(master)
|
||||
self.connect = None
|
||||
self.hostname_label = Label(self)
|
||||
self.user_name_label = Label(self)
|
||||
self.password_label = Label(self)
|
||||
self.connection_status = Label(self)
|
||||
self.hostname = Entry(self)
|
||||
self.user_name = Entry(self)
|
||||
self.password = Entry(self)
|
||||
self.list_projects = Button(self)
|
||||
self.fix_project = Button(self)
|
||||
self.create_project = Button(self)
|
||||
self.broad = Text(self)
|
||||
self.fix_project_label = Label(self)
|
||||
self.local_path_label = Label(self)
|
||||
self.get_branch = Button(self)
|
||||
self.set_local = Button(self)
|
||||
self.add_remote = Button(self)
|
||||
self.list_remote = Button(self)
|
||||
self.clone_project = Button(self)
|
||||
self.pull = Button(self)
|
||||
self.push = Button(self)
|
||||
self.add = Button(self)
|
||||
self.commit = Button(self)
|
||||
self.info = None
|
||||
|
||||
self.git = None
|
||||
self.draw_widget()
|
||||
|
||||
def do_connect(self):
|
||||
try:
|
||||
self.git = git.Git(hostname=self.hostname.get(),
|
||||
user=self.user_name.get(), passwd=self.password.get(),
|
||||
path="/home/git/")
|
||||
finally:
|
||||
self.connection_status["text"] = "Failed"
|
||||
self.connection_status["fg"] = "red"
|
||||
self.connection_status["text"] = "Succeed"
|
||||
self.connection_status["fg"] = "green"
|
||||
|
||||
self.git.base_init()
|
||||
self.git.update_projects()
|
||||
self.broad.insert(INSERT, "--------------------------\n")
|
||||
self.broad.insert(INSERT, "SSH Connection [Succeed]\n")
|
||||
self.broad.insert(INSERT, self.hostname.get()+"\n")
|
||||
self.broad.insert(INSERT, self.user_name.get()+"\n")
|
||||
|
||||
def do_list(self):
|
||||
self.git.list_projects()
|
||||
self.broad.insert(INSERT, "--------------------------\n")
|
||||
self.broad.insert(INSERT, "Projects: \n")
|
||||
for project in self.git.projects.items():
|
||||
print(project)
|
||||
self.broad.insert(INSERT, "(*) "+project[0]+"\n")
|
||||
|
||||
def new_project(self):
|
||||
self.info = Info(Tk())
|
||||
self.info.information_label["text"] = "Project Name: "
|
||||
self.info.set_click(self.new_project_callback)
|
||||
self.list_projects()
|
||||
|
||||
def do_fix_project(self):
|
||||
self.info = Info(Tk())
|
||||
self.info.information_label["text"] = "Project Name: "
|
||||
self.info.set_click(self.do_fix_project_callback)
|
||||
|
||||
def new_project_callback(self):
|
||||
if self.info is not None:
|
||||
self.git.create_project(self.info.information.get())
|
||||
self.info.master.destroy()
|
||||
self.info = None
|
||||
|
||||
def do_fix_project_callback(self):
|
||||
if self.info is not None:
|
||||
self.git.fix_project(self.info.information.get())
|
||||
self.fix_project_label["text"] = "Fixed Project: {0}".format(self.info.information.get())
|
||||
self.info.master.destroy()
|
||||
self.info = None
|
||||
self.do_get_branch()
|
||||
self.do_clone_project()
|
||||
self.do_add_remote()
|
||||
self.do_list_remote()
|
||||
|
||||
def do_get_branch(self):
|
||||
self.git.get_branch()
|
||||
self.broad.insert(INSERT, "--------------------------\n")
|
||||
self.broad.insert(INSERT, "Branches: \n")
|
||||
for branch in self.git.projects[self.git.fix_name]["branch"]:
|
||||
print(branch)
|
||||
self.broad.insert(INSERT, "(*) " + branch + "\n")
|
||||
|
||||
def do_set_local(self):
|
||||
self.info = Info(Tk())
|
||||
self.info.information_label["text"] = "Local Path: "
|
||||
self.info.information.insert(END, "C:\\Users\\Saturneric\\Documents\\Code\\")
|
||||
self.info.set_click(self.do_set_local_callback)
|
||||
|
||||
def do_set_local_callback(self):
|
||||
if self.info is not None:
|
||||
self.git.set_local(self.info.information.get())
|
||||
self.local_path_label["text"] = "Local Path: {0}".format(self.info.information.get())
|
||||
self.info.master.destroy()
|
||||
self.info = None
|
||||
|
||||
def do_clone_project(self):
|
||||
self.git.clone_project()
|
||||
self.git.add_remote()
|
||||
|
||||
def do_add_remote(self):
|
||||
self.git.add_remote("origin")
|
||||
|
||||
def do_list_remote(self):
|
||||
self.git.get_remote()
|
||||
self.broad.insert(INSERT, "--------------------------\n")
|
||||
self.broad.insert(INSERT, "Remotes: \n")
|
||||
for remote in self.git.remotes.items():
|
||||
print(remote)
|
||||
self.broad.insert(INSERT, "(*) " + remote[1]["name"] + " " + remote[1]["url"] + "\n")
|
||||
|
||||
def do_pull(self):
|
||||
self.git.pull_remote("origin", "master")
|
||||
|
||||
def do_push(self):
|
||||
self.git.push_remote("origin", "master")
|
||||
|
||||
def do_add(self):
|
||||
self.git.add()
|
||||
|
||||
def do_commit(self):
|
||||
self.info = Info(Tk())
|
||||
self.info.information_label["text"] = "Local Path: "
|
||||
self.info.information.insert(END, "Default")
|
||||
self.info.set_click(self.do_commit_callback)
|
||||
|
||||
def do_commit_callback(self):
|
||||
self.git.commit_local(self.info.information.get())
|
||||
self.info.master.destroy()
|
||||
self.info = None
|
||||
|
||||
def draw_widget(self):
|
||||
self.hostname_label["text"] = "Hostname: "
|
||||
self.hostname_label.grid(row=0, column=0)
|
||||
self.hostname.insert(END, "compute.bktus.com")
|
||||
self.hostname.grid(row=0, column=1)
|
||||
self.user_name_label["text"] = "Username: "
|
||||
self.user_name_label.grid(row=0, column=2)
|
||||
self.user_name.insert(END, "git")
|
||||
self.user_name.grid(row=0, column=3)
|
||||
self.password_label["text"] = "Password: "
|
||||
self.password_label.grid(row=0, column=4)
|
||||
self.password.grid(row=0, column=5)
|
||||
self.connection_status.grid(row=0, column=7)
|
||||
|
||||
self.connect = Button(self)
|
||||
self.connect["text"] = "Connect"
|
||||
self.connect["command"] = self.do_connect
|
||||
self.connect.grid(row=0, column=6)
|
||||
|
||||
self.list_projects["text"] = "List Projects"
|
||||
self.list_projects["command"] = self.do_list
|
||||
self.list_projects.grid(row=1, column=0)
|
||||
|
||||
self.fix_project["text"] = " Fix Project "
|
||||
self.fix_project["command"] = self.do_fix_project
|
||||
self.fix_project.grid(row=2, column=0)
|
||||
|
||||
self.create_project["text"] = "Create Project"
|
||||
self.create_project["command"] = self.new_project
|
||||
self.create_project.grid(row=1, column=1)
|
||||
|
||||
self.fix_project_label["text"] = "Fixed Project: None"
|
||||
self.fix_project_label.grid(row=8, column=6)
|
||||
self.local_path_label["text"] = "Local Path: None"
|
||||
self.local_path_label.grid(row=9, column=0, columnspan=6)
|
||||
|
||||
self.get_branch["text"] = "Get Branch"
|
||||
self.get_branch["command"] = self.do_get_branch
|
||||
self.get_branch.grid(row=3,column=0)
|
||||
|
||||
self.set_local["text"] = "Set Local"
|
||||
self.set_local["command"] = self.do_set_local
|
||||
self.set_local.grid(row=3, column=1)
|
||||
|
||||
self.clone_project["text"] = "Clone Project"
|
||||
self.clone_project["command"] = self.do_clone_project
|
||||
self.clone_project.grid(row=2, column=1)
|
||||
|
||||
self.add_remote["text"] = "Add Remote"
|
||||
self.add_remote["command"] = self.do_add_remote
|
||||
self.add_remote.grid(row=4, column=0)
|
||||
|
||||
self.list_remote["text"] = "List Remote"
|
||||
self.list_remote["command"] = self.do_list_remote
|
||||
self.list_remote.grid(row=4, column=1)
|
||||
|
||||
self.pull["text"] = "Pull"
|
||||
self.pull["command"] = self.do_pull
|
||||
self.pull.grid(row=5, column=0)
|
||||
|
||||
self.push["text"] = "Push"
|
||||
self.push["command"] = self.do_push
|
||||
self.push.grid(row=5, column=1)
|
||||
|
||||
self.add["text"] = "Add"
|
||||
self.add["command"] = self.do_add
|
||||
self.add.grid(row=6, column=0)
|
||||
|
||||
self.commit["text"] = "Commit"
|
||||
self.commit["command"] = self.do_commit
|
||||
self.commit.grid(row=6, column=1)
|
||||
|
||||
self.broad.grid(row=1, column=2, columnspan=7, rowspan=6)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
root = Tk()
|
||||
main = Main(root)
|
||||
main.set_width(900)
|
||||
main.apply()
|
||||
main.mainloop()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user