# Conflicts:
#	.idea/workspace.xml
#	git.py
This commit is contained in:
Saturneic 2019-03-14 01:13:53 +08:00
commit 95ebb9af11
7 changed files with 67 additions and 79 deletions

BIN
.DS_Store vendored

Binary file not shown.

33
.idea/workspace.xml generated
View File

@ -74,8 +74,8 @@
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/git.py"> <entry file="file://$PROJECT_DIR$/git.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="454"> <state relative-caret-position="226">
<caret line="233" column="34" lean-forward="true" selection-start-line="233" selection-start-column="34" selection-end-line="233" selection-end-column="34" /> <caret line="49" column="42" selection-start-line="49" selection-start-column="42" selection-end-line="49" selection-end-column="42" />
<folding> <folding>
<element signature="e#0#9#0" expanded="true" /> <element signature="e#0#9#0" expanded="true" />
<marker date="1552496550761" expanded="true" signature="13921:14647" ph="..." /> <marker date="1552496550761" expanded="true" signature="13921:14647" ph="..." />
@ -96,7 +96,7 @@
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/keygen.py"> <entry file="file://$PROJECT_DIR$/keygen.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="360"> <state relative-caret-position="120">
<caret line="27" column="27" selection-start-line="27" selection-start-column="27" selection-end-line="27" selection-end-column="27" /> <caret line="27" column="27" selection-start-line="27" selection-start-column="27" selection-end-line="27" selection-end-column="27" />
<folding> <folding>
<element signature="e#0#10#0" expanded="true" /> <element signature="e#0#10#0" expanded="true" />
@ -219,8 +219,6 @@
<option value="$PROJECT_DIR$/info.py" /> <option value="$PROJECT_DIR$/info.py" />
<option value="$PROJECT_DIR$/branchmanager.py" /> <option value="$PROJECT_DIR$/branchmanager.py" />
<option value="$PROJECT_DIR$/main.py" /> <option value="$PROJECT_DIR$/main.py" />
<option value="$PROJECT_DIR$/ssh.py" />
<option value="$PROJECT_DIR$/git.py" />
</list> </list>
</option> </option>
</component> </component>
@ -480,20 +478,19 @@
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="0" y="23" width="1440" height="811" extended-state="0" /> <frame x="0" y="23" width="1440" height="811" extended-state="0" />
<editor active="true" />
<layout> <layout>
<window_info id="Favorites" order="0" side_tool="true" /> <window_info id="Favorites" order="0" side_tool="true" />
<window_info content_ui="combo" id="Project" order="1" visible="true" weight="0.1509299" /> <window_info content_ui="combo" id="Project" order="1" visible="true" weight="0.14663805" />
<window_info id="Structure" order="2" side_tool="true" weight="0.25" /> <window_info id="Structure" order="2" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Database Changes" order="0" show_stripe_button="false" /> <window_info anchor="bottom" id="Database Changes" order="0" show_stripe_button="false" />
<window_info anchor="bottom" id="Terminal" order="1" sideWeight="0.4985694" weight="0.32962447" /> <window_info anchor="bottom" id="Terminal" order="1" sideWeight="0.4985694" weight="0.32962447" />
<window_info active="true" anchor="bottom" id="Event Log" order="2" sideWeight="0.50214595" side_tool="true" visible="true" weight="0.32962447" /> <window_info anchor="bottom" id="Event Log" order="2" sideWeight="0.50500715" side_tool="true" visible="true" weight="0.2628651" />
<window_info anchor="bottom" id="Version Control" order="3" sideWeight="0.49785408" visible="true" weight="0.32962447" /> <window_info anchor="bottom" id="Version Control" order="3" sideWeight="0.4985694" weight="0.32962447" />
<window_info anchor="bottom" id="Python Console" order="4" weight="0.3286517" /> <window_info anchor="bottom" id="Python Console" order="4" weight="0.3286517" />
<window_info anchor="bottom" id="Docker" order="5" show_stripe_button="false" /> <window_info anchor="bottom" id="Docker" order="5" show_stripe_button="false" />
<window_info anchor="bottom" id="Message" order="6" /> <window_info anchor="bottom" id="Message" order="6" />
<window_info anchor="bottom" id="Find" order="7" weight="0.329718" /> <window_info anchor="bottom" id="Find" order="7" weight="0.329718" />
<window_info anchor="bottom" id="Run" order="8" sideWeight="0.49427754" weight="0.2628651" /> <window_info anchor="bottom" id="Run" order="8" sideWeight="0.49499285" weight="0.2628651" />
<window_info anchor="bottom" id="Debug" order="9" sideWeight="0.49928468" weight="0.30737135" /> <window_info anchor="bottom" id="Debug" order="9" sideWeight="0.49928468" weight="0.30737135" />
<window_info anchor="bottom" id="Cvs" order="10" weight="0.25" /> <window_info anchor="bottom" id="Cvs" order="10" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="11" weight="0.4" /> <window_info anchor="bottom" id="Inspection" order="11" weight="0.4" />
@ -574,17 +571,10 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/branchmanager.py"> <entry file="file://$PROJECT_DIR$/branchmanager.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="900"> <state relative-caret-position="120">
<caret line="66" column="24" selection-start-line="66" selection-start-column="24" selection-end-line="66" selection-end-column="24" /> <caret line="8" column="27" selection-start-line="8" selection-start-column="27" selection-end-line="8" selection-end-column="27" />
<folding> <folding>
<element signature="e#0#21#0" expanded="true" /> <element signature="e#0#21#0" expanded="true" />
<marker date="1552415132051" expanded="true" signature="178:183" ph="..." />
<marker date="1552415132051" expanded="true" signature="2638:3140" ph="..." />
<marker date="1552415132051" expanded="true" signature="3158:3361" ph="..." />
<marker date="1552415132051" expanded="true" signature="3378:3493" ph="..." />
<marker date="1552415132051" expanded="true" signature="3519:3983" ph="..." />
<marker date="1552415132051" expanded="true" signature="4005:4694" ph="..." />
<marker date="1552415132051" expanded="true" signature="5012:5663" ph="..." />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -604,7 +594,8 @@
<state relative-caret-position="360"> <state relative-caret-position="360">
<caret line="27" column="27" selection-start-line="27" selection-start-column="27" selection-end-line="27" selection-end-column="27" /> <caret line="27" column="27" selection-start-line="27" selection-start-column="27" selection-end-line="27" selection-end-column="27" />
<folding> <folding>
<element signature="e#0#10#0" expanded="true" /> <element signature="e#0#21#0" expanded="true" />
<marker date="1552409960112" expanded="true" signature="1144:1635" ph="..." />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -626,7 +617,7 @@
<caret line="93" column="22" lean-forward="true" selection-start-line="93" selection-start-column="22" selection-end-line="93" selection-end-column="22" /> <caret line="93" column="22" lean-forward="true" selection-start-line="93" selection-start-column="22" selection-end-line="93" selection-end-column="22" />
<folding> <folding>
<element signature="e#0#21#0" expanded="true" /> <element signature="e#0#21#0" expanded="true" />
<marker date="1552494762449" expanded="true" signature="16338:16344" ph="..." /> <marker date="1552453766451" expanded="true" signature="15701:15707" ph="..." />
</folding> </folding>
</state> </state>
</provider> </provider>

View File

@ -25,6 +25,7 @@ class Changes(window.Window):
self.list.bind("<<ListboxSelect>>",self.show_change) self.list.bind("<<ListboxSelect>>",self.show_change)
self.current_index = None self.current_index = None
self.broad = broad self.broad = broad
self.list_bak = []
def draw_widgets(self): def draw_widgets(self):
self.list.grid(row=0, column=0) self.list.grid(row=0, column=0)
@ -67,6 +68,7 @@ class Changes(window.Window):
def show_change(self, *args): def show_change(self, *args):
if len(self.list_bak) > 0:
self.current_index = self.list.curselection()[0] self.current_index = self.list.curselection()[0]
if self.discard_status[self.current_index]: if self.discard_status[self.current_index]:
self.discard['text'] = 'Discard' self.discard['text'] = 'Discard'
@ -106,6 +108,7 @@ class Changes(window.Window):
def set_list(self, list): def set_list(self, list):
for item in list: for item in list:
self.list.insert(END, item) self.list.insert(END, item)
self.list_bak =list
ret_code = re.compile(r"[:]") ret_code = re.compile(r"[:]")
tmp_ret = ret_code.split(item) tmp_ret = ret_code.split(item)
self.change_files.append(tmp_ret[1]) self.change_files.append(tmp_ret[1])

10
git.py
View File

@ -215,15 +215,9 @@ class Git(ssh.SSH):
self.get_branch_server() self.get_branch_server()
if name in self.remotes.keys(): if name in self.remotes.keys():
if branch not in self.branches_server: if branch not in self.branches_server:
proc = subprocess.Popen("git push -u {0} {1}".format(name, branch), stderr=subprocess.STDOUT, return os.popen("git push -u {0} {1}".format(name, branch)).read()
stdout=subprocess.PIPE)
stdout, stderr = proc.comunicate(timeout=30)
return stdout.decode("utf-8")
else: else:
proc = subprocess.Popen("git push {0} {1}".format(name, branch), stderr=subprocess.STDOUT, return os.popen("git push {0} {1}".format(name, branch)).read()
stdout=subprocess.PIPE)
stdout, stderr = proc.comunicate(timeout=30)
return stdout.decode("utf-8")
else: else:
raise ValueError("Name Abnormal") raise ValueError("Name Abnormal")
else: else:

View File

@ -10,8 +10,8 @@ class Key(ssh.SSH):
self.connect(5) self.connect(5)
self.pub_key = None self.pub_key = None
self.keygen = None self.keygen = None
self.local_path = "/Users/huyibing/" self.local_path = os.path.expanduser('~')
self.public_key_path = self.local_path+".ssh/id_rsa.pub" self.public_key_path = os.path.join(self.local_path, '.ssh', 'id_rsa.pub')
self.public_key = None self.public_key = None
def add_key(self): def add_key(self):
@ -20,14 +20,14 @@ class Key(ssh.SSH):
@staticmethod @staticmethod
def create_key(): def create_key():
if os.path.exists(os.path.join(os.environ["HOME"],".ssh","id_rsa.pub")): if os.path.exists(os.path.join(os.path.expanduser('~'),".ssh","id_rsa.pub")):
os.remove(os.path.join(os.environ["HOME"],".ssh","id_rsa.pub")) os.remove(os.path.join(os.path.expanduser('~'),".ssh","id_rsa.pub"))
os.remove(os.path.join(os.environ["HOME"], ".ssh", "id_rsa")) os.remove(os.path.join(os.path.expanduser('~'), ".ssh", "id_rsa"))
print("Key Path:","{0}".format(os.path.join(os.environ["HOME"],".ssh","id_rsa"))) print("Key Path:","{0}".format(os.path.join(os.path.expanduser('~'),".ssh","id_rsa")))
ret_code = subprocess.Popen(["ssh-keygen", "-b 4096","-N ''", "-q", ret_code = subprocess.Popen(["ssh-keygen", "-b 4096","-N ''", "-q",
"-f {0}".format(os.path.join(os.environ["HOME"],".ssh","id_rsa")), "-f {0}".format(os.path.join(os.path.expanduser('~'),".ssh","id_rsa")),
], shell=True, ], shell=False,
stdin=subprocess.PIPE, stdout=subprocess.PIPE) stdin=subprocess.PIPE, stdout=subprocess.PIPE)
stdout, stderr = ret_code.communicate(input=b"\ny\n") stdout, stderr = ret_code.communicate(input=b"\ny\n")
return stdout.decode("utf-8") return stdout.decode("utf-8")

16
main.py
View File

@ -18,14 +18,14 @@ class Main(window.Window):
master.title("GitEasy") master.title("GitEasy")
self.style.configure("M.MButton",) self.style.configure("M.MButton",)
self.connect = None self.connect = None
self.hostname_label = Label(self, width=8) self.hostname_label = Label(self, width=10)
self.user_name_label = Label(self, width=12) self.user_name_label = Label(self, width=12)
self.password_label = Label(self, width=8) self.password_label = Label(self, width=8)
self.connection_status = Label(self, width=8) self.connection_status = Label(self, width=8)
self.hostname = Entry(self, width=15) self.hostname = Entry(self, width=15)
self.user_name = Entry(self, width=15) self.user_name = Entry(self, width=15)
self.password = Entry(self, width=15, show="*") self.password = Entry(self, width=15, show="*")
self.list_projects = Button(self, width=12) self.list_projects = Button(self, width=13)
self.fix_project = Button(self, width=12) self.fix_project = Button(self, width=12)
self.create_project = Button(self, width=12) self.create_project = Button(self, width=12)
self.broad = Text(self, width=85, height=30) self.broad = Text(self, width=85, height=30)
@ -35,13 +35,13 @@ class Main(window.Window):
self.set_local = Button(self, width=12) self.set_local = Button(self, width=12)
self.add_remote = Button(self, width=12) self.add_remote = Button(self, width=12)
self.list_remote = Button(self, width=12) self.list_remote = Button(self, width=12)
self.clone_project = Button(self, width=12) self.clone_project = Button(self, width=13)
self.project_status = Button(self, width=12) self.project_status = Button(self, width=12)
self.pull = Button(self, width=12) self.pull = Button(self, width=12)
self.push = Button(self, width=12) self.push = Button(self, width=12)
self.add = Button(self, width=12) self.add = Button(self, width=12)
self.commit = Button(self, width=12) self.commit = Button(self, width=12)
self.save = Button(self, width=12) self.save = Button(self, width=15)
self.ssh_tools = Button(self, width=12) self.ssh_tools = Button(self, width=12)
self.info = None self.info = None
self.save_info = None self.save_info = None
@ -49,11 +49,11 @@ class Main(window.Window):
self.git = None self.git = None
self.draw_widget() self.draw_widget()
if os.path.exists(os.path.join(os.environ['HOME'],"save_data.json")): if os.path.exists(os.path.join(os.path.expanduser('~'),"save_data.json")):
self.get_save_data() self.get_save_data()
def get_save_data(self): def get_save_data(self):
save_file = open(os.path.join(os.environ['HOME'],"save_data.json"),"r") save_file = open(os.path.join(os.path.expanduser('~'),"save_data.json"),"r")
json_data = save_file.readline() json_data = save_file.readline()
save_infos = json.loads(json_data) save_infos = json.loads(json_data)
self.save_info = save_infos[0] self.save_info = save_infos[0]
@ -336,12 +336,12 @@ class Main(window.Window):
save_info["fix_project"] = self.git.fix_name save_info["fix_project"] = self.git.fix_name
save_infos.append(save_info) save_infos.append(save_info)
json_info = json.dumps(save_infos) json_info = json.dumps(save_infos)
save_file = open(os.path.join(os.environ['HOME'],"save_data.json"),"w") save_file = open(os.path.join(os.path.expanduser('~'),"save_data.json"),"w")
save_file.write(json_info) save_file.write(json_info)
save_file.close() save_file.close()
self.broad.insert(INSERT, "--------------------------\n") self.broad.insert(INSERT, "--------------------------\n")
self.broad.insert(INSERT, "Data Information Saved\n") self.broad.insert(INSERT, "Data Information Saved\n")
self.broad.insert(INSERT, "Path: "+os.path.join(os.environ['HOME'],"save_data.json")) self.broad.insert(INSERT, "Path: "+os.path.join(os.path.expanduser('~'), "save_data.json"))
self.broad.see(END) self.broad.see(END)
else: else:
raise AttributeError("Please Connect And Set Local Path First.") raise AttributeError("Please Connect And Set Local Path First.")

View File

@ -33,8 +33,8 @@ class SSH_Tools(window.Window,Key):
self.broad.see(END) self.broad.see(END)
def do_check_key(self): def do_check_key(self):
ret_code = subprocess.Popen("ssh -T {0}@{1}".format(self.user, self.hostname), ret_code = subprocess.Popen("ssh -o StrictHostKeyChecking=no -T {0}@{1}".format(self.user, self.hostname),
shell=True, shell=False,
stdin=subprocess.PIPE, stdout=subprocess.PIPE stdin=subprocess.PIPE, stdout=subprocess.PIPE
) )
stdout, stderr = ret_code.communicate(input=b"\x03") stdout, stderr = ret_code.communicate(input=b"\x03")