Fixed and Added.

This commit is contained in:
Saturneic 2019-03-14 01:10:27 +08:00
parent 0a70306c97
commit 673a9c9ce5
4 changed files with 115 additions and 78 deletions

157
.idea/workspace.xml generated
View File

@ -2,7 +2,10 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="d703f139-38f3-455d-a086-a2da561870b5" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/git.py" beforeDir="false" afterPath="$PROJECT_DIR$/git.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ssh.py" beforeDir="false" afterPath="$PROJECT_DIR$/ssh.py" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
@ -11,7 +14,7 @@
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="CoverageDataManager">
<SUITE FILE_PATH="coverage/giteasy$main.coverage" NAME="main Coverage Results" MODIFIED="1552453031291" 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$main.coverage" NAME="main Coverage Results" MODIFIED="1552496462912" 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="1552305147101" 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$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$window.coverage" NAME="window Coverage Results" MODIFIED="1552378199288" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
@ -36,20 +39,22 @@
<session id="46200952">
<usages-collector id="statistics.lifecycle.project">
<counts>
<entry key="project.closed" value="2" />
<entry key="project.closed" value="3" />
<entry key="project.open.time.0" value="1" />
<entry key="project.open.time.13" value="1" />
<entry key="project.open.time.16" value="1" />
<entry key="project.opened" value="2" />
<entry key="project.open.time.8" value="1" />
<entry key="project.opened" value="4" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.extensions.edit">
<counts>
<entry key="py" value="11693" />
<entry key="py" value="11904" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.types.edit">
<counts>
<entry key="Python" value="11693" />
<entry key="Python" value="11904" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.extensions.open">
@ -69,21 +74,21 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/git.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="226">
<caret line="49" column="42" selection-start-line="49" selection-start-column="42" selection-end-line="49" selection-end-column="42" />
<state relative-caret-position="454">
<caret line="233" column="34" lean-forward="true" selection-start-line="233" selection-start-column="34" selection-end-line="233" selection-end-column="34" />
<folding>
<element signature="e#0#9#0" expanded="true" />
<marker date="1552453029448" expanded="true" signature="13269:13995" ph="..." />
<marker date="1552496550761" expanded="true" signature="13921:14647" ph="..." />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/ssh.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="60">
<caret line="25" selection-start-line="25" selection-end-line="25" />
<state relative-caret-position="-282">
<caret line="4" column="30" selection-start-line="4" selection-start-column="30" selection-end-line="4" selection-end-column="30" />
</state>
</provider>
</entry>
@ -91,7 +96,7 @@
<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="120">
<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" />
<folding>
<element signature="e#0#10#0" expanded="true" />
@ -103,7 +108,7 @@
<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="45">
<state relative-caret-position="75">
<caret line="7" column="15" selection-start-line="7" selection-start-column="8" selection-end-line="7" selection-end-column="15" />
<folding>
<element signature="e#0#21#0" expanded="true" />
@ -112,14 +117,14 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="104">
<caret line="73" column="16" lean-forward="true" selection-start-line="73" selection-start-column="16" selection-end-line="73" selection-end-column="16" />
<state relative-caret-position="414">
<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>
<element signature="e#0#21#0" expanded="true" />
<marker date="1552453766451" expanded="true" signature="15701:15707" ph="..." />
<marker date="1552494762449" expanded="true" signature="16338:16344" ph="..." />
</folding>
</state>
</provider>
@ -128,7 +133,7 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/info.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="120">
<state relative-caret-position="75">
<caret line="8" column="27" selection-start-line="8" selection-start-column="27" selection-end-line="8" selection-end-column="27" />
<folding>
<element signature="e#0#21#0" expanded="true" />
@ -140,7 +145,7 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/change.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="26">
<state relative-caret-position="135">
<caret line="14" column="37" selection-start-line="14" selection-start-column="37" selection-end-line="14" selection-end-column="37" />
<folding>
<element signature="e#0#21#0" expanded="true" />
@ -152,7 +157,7 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/sshtool.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-331">
<state relative-caret-position="15">
<caret line="6" selection-start-line="6" selection-end-line="6" />
<folding>
<element signature="e#0#21#0" expanded="true" />
@ -165,7 +170,7 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/branchmanager.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="30">
<state relative-caret-position="900">
<caret line="66" column="24" selection-start-line="66" selection-start-column="24" selection-end-line="66" selection-end-column="24" />
<folding>
<element signature="e#0#21#0" expanded="true" />
@ -206,7 +211,6 @@
<list>
<option value="$PROJECT_DIR$/lib/ssh.py" />
<option value="$PROJECT_DIR$/venv/ssh.py" />
<option value="$PROJECT_DIR$/ssh.py" />
<option value="$PROJECT_DIR$/server.py" />
<option value="$PROJECT_DIR$/window.py" />
<option value="$PROJECT_DIR$/keygen.py" />
@ -214,8 +218,9 @@
<option value="$PROJECT_DIR$/sshtool.py" />
<option value="$PROJECT_DIR$/info.py" />
<option value="$PROJECT_DIR$/branchmanager.py" />
<option value="$PROJECT_DIR$/git.py" />
<option value="$PROJECT_DIR$/main.py" />
<option value="$PROJECT_DIR$/ssh.py" />
<option value="$PROJECT_DIR$/git.py" />
</list>
</option>
</component>
@ -460,7 +465,14 @@
<option name="project" value="LOCAL" />
<updated>1552383089132</updated>
</task>
<option name="localTasksCounter" value="4" />
<task id="LOCAL-00004" summary="Fixed and Added.">
<created>1552464026502</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1552464026503</updated>
</task>
<option name="localTasksCounter" value="5" />
<servers />
</component>
<component name="TimeTrackingManager">
@ -468,19 +480,20 @@
</component>
<component name="ToolWindowManager">
<frame x="0" y="23" width="1440" height="811" extended-state="0" />
<editor active="true" />
<layout>
<window_info id="Favorites" order="0" side_tool="true" />
<window_info content_ui="combo" id="Project" order="1" visible="true" weight="0.14663805" />
<window_info content_ui="combo" id="Project" order="1" visible="true" weight="0.1509299" />
<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="Terminal" order="1" sideWeight="0.4985694" 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.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="Version Control" order="3" sideWeight="0.49785408" visible="true" weight="0.32962447" />
<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="Message" order="6" />
<window_info anchor="bottom" id="Find" order="7" weight="0.329718" />
<window_info anchor="bottom" id="Run" order="8" sideWeight="0.49499285" weight="0.2628651" />
<window_info anchor="bottom" id="Run" order="8" sideWeight="0.49427754" weight="0.2628651" />
<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="Inspection" order="11" weight="0.4" />
@ -528,19 +541,40 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/keygen.py">
<entry file="file://$PROJECT_DIR$/info.py">
<provider selected="true" editor-type-id="text-editor">
<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" />
<state relative-caret-position="75">
<caret line="8" column="27" selection-start-line="8" selection-start-column="27" selection-end-line="8" selection-end-column="27" />
<folding>
<element signature="e#0#10#0" expanded="true" />
<element signature="e#0#21#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/change.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="135">
<caret line="14" column="37" selection-start-line="14" selection-start-column="37" selection-end-line="14" selection-end-column="37" />
<folding>
<element signature="e#0#21#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/sshtool.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="15">
<caret line="6" selection-start-line="6" selection-end-line="6" />
<folding>
<element signature="e#0#21#0" expanded="true" />
<marker date="1552409960112" expanded="true" signature="1144:1635" ph="..." />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/branchmanager.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="30">
<state relative-caret-position="900">
<caret line="66" column="24" selection-start-line="66" selection-start-column="24" selection-end-line="66" selection-end-column="24" />
<folding>
<element signature="e#0#21#0" expanded="true" />
@ -557,7 +591,7 @@
</entry>
<entry file="file://$PROJECT_DIR$/window.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="45">
<state relative-caret-position="75">
<caret line="7" column="15" selection-start-line="7" selection-start-column="8" selection-end-line="7" selection-end-column="15" />
<folding>
<element signature="e#0#21#0" expanded="true" />
@ -565,65 +599,44 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/ssh.py">
<entry file="file://$PROJECT_DIR$/keygen.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="60">
<caret line="25" selection-start-line="25" selection-end-line="25" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/info.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="120">
<caret line="8" column="27" selection-start-line="8" selection-start-column="27" selection-end-line="8" selection-end-column="27" />
<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" />
<folding>
<element signature="e#0#21#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/change.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="26">
<caret line="14" column="37" selection-start-line="14" selection-start-column="37" selection-end-line="14" selection-end-column="37" />
<folding>
<element signature="e#0#21#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/sshtool.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-331">
<caret line="6" selection-start-line="6" selection-end-line="6" />
<folding>
<element signature="e#0#21#0" expanded="true" />
<marker date="1552409960112" expanded="true" signature="1144:1635" ph="..." />
<element signature="e#0#10#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/git.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="226">
<caret line="49" column="42" selection-start-line="49" selection-start-column="42" selection-end-line="49" selection-end-column="42" />
<state relative-caret-position="454">
<caret line="233" column="34" lean-forward="true" selection-start-line="233" selection-start-column="34" selection-end-line="233" selection-end-column="34" />
<folding>
<element signature="e#0#9#0" expanded="true" />
<marker date="1552453029448" expanded="true" signature="13269:13995" ph="..." />
<marker date="1552496550761" expanded="true" signature="13921:14647" ph="..." />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="104">
<caret line="73" column="16" lean-forward="true" selection-start-line="73" selection-start-column="16" selection-end-line="73" selection-end-column="16" />
<state relative-caret-position="414">
<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>
<element signature="e#0#21#0" expanded="true" />
<marker date="1552453766451" expanded="true" signature="15701:15707" ph="..." />
<marker date="1552494762449" expanded="true" signature="16338:16344" ph="..." />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/ssh.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-282">
<caret line="4" column="30" selection-start-line="4" selection-start-column="30" selection-end-line="4" selection-end-column="30" />
</state>
</provider>
</entry>
</component>
</project>

16
git.py
View File

@ -1,6 +1,7 @@
import re
import os
import ssh
import subprocess
class Git(ssh.SSH):
@ -214,9 +215,15 @@ class Git(ssh.SSH):
self.get_branch_server()
if name in self.remotes.keys():
if branch not in self.branches_server:
return os.popen("git push -u {0} {1}".format(name, branch)).read()
proc = subprocess.Popen("git push -u {0} {1}".format(name, branch), stderr=subprocess.STDOUT,
stdout=subprocess.PIPE)
stdout, stderr = proc.comunicate(timeout=30)
return stdout.decode("utf-8")
else:
return os.popen("git push {0} {1}".format(name, branch)).read()
proc = subprocess.Popen("git push {0} {1}".format(name, branch), stderr=subprocess.STDOUT,
stdout=subprocess.PIPE)
stdout, stderr = proc.comunicate(timeout=30)
return stdout.decode("utf-8")
else:
raise ValueError("Name Abnormal")
else:
@ -228,7 +235,10 @@ class Git(ssh.SSH):
self.get_branch_server()
if name in self.remotes.keys():
if branch in self.branches_server:
return os.popen("git pull {0} {1}".format(name, branch)).read()
proc = subprocess.Popen(["git pull", "{0} {1}".format(name, branch)], shell=True, stderr=subprocess.STDOUT,
stdout=subprocess.PIPE)
stdout, stderr = proc.comunicate(timeout=30)
return stdout.decode("utf-8")
else: return "Current Branch '{0}' Not Exist In Server.".format(branch)
else:
raise ValueError("Remote Error")

13
main.py
View File

@ -80,6 +80,19 @@ class Main(window.Window):
showinfo(message="Authentication failed.")
return
except paramiko.ssh_exception.BadHostKeyException:
self.connection_status["text"] = "Failed"
showinfo(message="Bad HostKey.")
return
except paramiko.ssh_exception.SSHException:
self.connection_status["text"] = "Failed"
showinfo(message="There was any other error connecting or establishing an SSH session.")
return
except paramiko.socket.error:
self.connection_status["text"] = "Failed"
showinfo(message="A socket error occurred while connecting.")
return
self.connection_status["text"] = "Succeed"
try:

7
ssh.py
View File

@ -2,7 +2,7 @@ import paramiko
class SSH(object):
ssh = paramiko.SSHClient();
ssh = paramiko.SSHClient()
def __init__(self, hostname, path, user, passwd=None, ssh_key=False):
self.hostname = hostname
@ -38,10 +38,11 @@ class SSH(object):
def connect(self, timeout):
if self.ssh_key:
self.ssh.connect(hostname=self.hostname, port=22, username=self.user, pkey=self.key, timeout=timeout)
self.ssh.connect(hostname=self.hostname, port=22, username=self.user, pkey=self.key,
timeout=timeout, look_for_keys=True)
else:
self.ssh.connect(hostname=self.hostname, port=22, username=self.user, password=self.passwd,
timeout=timeout)
timeout=timeout, look_for_keys = True)
def __del__(self):
self.close()