Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 438aea4

Browse files
fix git and update library version
1 parent 081ded0 commit 438aea4

File tree

5 files changed

+101
-61
lines changed

5 files changed

+101
-61
lines changed

‎.vscode/launch.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
// 使用 IntelliSense 了解相关属性。
3+
// 悬停以查看现有属性的描述。
4+
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [{
7+
"name": "PyQtClient",
8+
"type": "python",
9+
"request": "launch",
10+
"program": "${workspaceFolder}/PyQtClient.py",
11+
"console": "integratedTerminal",
12+
"cwd": "${workspaceFolder}",
13+
"env": {
14+
"PYTHONPATH": "${workspaceFolder}"
15+
}
16+
}]
17+
}

‎PyQtClient.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
@description:
1010
"""
1111

12-
from distutils.sysconfig import get_python_lib
1312
import os
1413
import sys
1514
import traceback
15+
from distutils.sysconfig import get_python_lib
1616

17+
sys.path.append(os.path.dirname(sys.argv[0]))
1718
sys.path.append(os.path.abspath('Library.zip'))
1819

1920
libpath = get_python_lib()
@@ -28,8 +29,6 @@
2829
os.environ['PATH'] = os.path.dirname(os.path.abspath(
2930
sys.argv[0])) + os.pathsep + os.environ['PATH']
3031

31-
print(os.environ['PATH'])
32-
3332

3433
def escape(s):
3534
s = s.replace("&", "&")
@@ -43,9 +42,9 @@ def escape(s):
4342

4443

4544
def showError(message):
46-
from PyQt5.QtWidgets import QApplication, QErrorMessage, QCheckBox, \
47-
QPushButton, QLabel, QStyle
4845
from PyQt5.QtCore import Qt
46+
from PyQt5.QtWidgets import (QApplication, QCheckBox, QErrorMessage, QLabel,
47+
QPushButton, QStyle)
4948
app = QApplication(sys.argv)
5049
app.setQuitOnLastWindowClosed(True)
5150
# 设置内置错误图标
@@ -72,6 +71,7 @@ def do_analysis():
7271
from pycallgraph2.globbing_filter import GlobbingFilter
7372
from pycallgraph2.output.graphviz import GraphvizOutput
7473
from pycallgraph2.pycallgraph import PyCallGraph
74+
7575
# 函数流程图调用
7676
config = Config()
7777
config.trace_filter = GlobbingFilter(

‎Utils/GitThread.py

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import pygit2
2121
import requests
22-
from pygit2.remote import RemoteCallbacks
2322
from PyQt5.QtCore import QCoreApplication, QObject, Qt, QThread
2423
from PyQt5.QtGui import QImage
2524
from requests.auth import HTTPBasicAuth
@@ -140,7 +139,7 @@ def run(self):
140139
LoginThread.quit()
141140

142141

143-
class ProgressCallback(RemoteCallbacks):
142+
class ProgressCallback(pygit2.RemoteCallbacks):
144143
"""clone过程中的进度条
145144
"""
146145

@@ -155,7 +154,8 @@ class CloneThread(QObject):
155154
"""获取项目源码
156155
"""
157156

158-
Url = 'git://github.com/PyQt5/PyQt.git'
157+
UrlGithub = 'https://github.com/PyQt5/PyQt.git'
158+
UrlGitee = 'https://gitee.com/PyQt5/PyQt.git'
159159

160160
@classmethod
161161
def quit(cls):
@@ -179,16 +179,19 @@ def start(cls, parent=None):
179179
cls._thread.start()
180180
AppLog.info('clone thread started')
181181

182-
def pull(self, repo, remote_name='origin', branch='master'):
182+
def pull(self, repo, remote_name='github,gitee', branch='master'):
183183
""" pull changes for the specified remote (defaults to origin).
184184
185185
Code from MichaelBoselowitz at:
186186
https://github.com/MichaelBoselowitz/pygit2-examples/blob/
187187
68e889e50a592d30ab4105a2e7b9f28fac7324c8/examples.py#L58
188188
licensed under the MIT license.
189189
"""
190+
repo.remotes.set_url('gitee', self.UrlGitee)
191+
repo.remotes.set_url('github', self.UrlGithub)
190192
for remote in repo.remotes:
191-
if remote.name == remote_name:
193+
if remote.name in remote_name:
194+
AppLog.info('update from: {}'.format(remote.name))
192195
remote.fetch()
193196
remote_master_id = repo.lookup_reference(
194197
'refs/remotes/origin/%s' % (branch)).target
@@ -206,12 +209,16 @@ def pull(self, repo, remote_name='origin', branch='master'):
206209
except KeyError:
207210
repo.create_branch(branch, repo.get(remote_master_id))
208211
repo.head.set_target(remote_master_id)
212+
return
209213
elif merge_result & pygit2.GIT_MERGE_ANALYSIS_NORMAL:
210214
repo.merge(remote_master_id)
211215

212216
if repo.index.conflicts is not None:
213217
for conflict in repo.index.conflicts:
214-
print('Conflicts found in:', conflict[0].path)
218+
for c in conflict:
219+
if not c:
220+
continue
221+
AppLog.error('Conflicts found in: %s', c.path)
215222
raise AssertionError('Conflicts, ahhhhh!!')
216223

217224
user = repo.default_signature
@@ -221,6 +228,7 @@ def pull(self, repo, remote_name='origin', branch='master'):
221228
# We need to do this or git CLI will think we are still
222229
# merging.
223230
repo.state_cleanup()
231+
return
224232
else:
225233
raise AssertionError('Unknown merge analysis result')
226234

@@ -230,37 +238,46 @@ def remove(self):
230238
path.chmod(stat.S_IWRITE)
231239
shutil.rmtree(Constants.DirProjects, ignore_errors=True)
232240

233-
def clone(self):
241+
def clone(self, url):
234242
"""克隆项目"""
235-
pygit2.clone_repository(self.Url,
243+
AppLog.info('clone from: {}'.format(url))
244+
pygit2.clone_repository(url,
236245
Constants.DirProjects,
237246
callbacks=ProgressCallback())
238247

239-
def run(self):
240-
try:
241-
path=pygit2.discover_repository(Constants.DirProjects)
242-
ifnotpath:
248+
def _clone(self):
249+
ok=False
250+
forurlin (self.UrlGithub, self.UrlGitee):
251+
try:
243252
# 本地项目不存在
244253
if os.path.exists(Constants.DirProjects):
245254
# 如果文件夹存在则删除
246255
AppLog.info('remove dir: {}'.format(Constants.DirProjects))
247256
self.remove()
248257
AppLog.info('clone into dir: {}'.format(Constants.DirProjects))
249-
self.clone()
258+
Signals.progressUpdated.emit(5, 100)
259+
self.clone(url)
260+
ok = True
261+
break
262+
except Exception as e:
263+
AppLog.error(str(e))
264+
if not ok:
265+
raise Exception('clone failed')
266+
267+
def run(self):
268+
try:
269+
path = pygit2.discover_repository(Constants.DirProjects)
270+
if not path:
271+
self._clone()
250272
else:
251273
repo = pygit2.Repository(path)
252274
if repo.is_empty: # 如果项目为空
253-
if os.path.exists(Constants.DirProjects):
254-
# 如果文件夹存在则删除
255-
AppLog.info('remove dir: {}'.format(
256-
Constants.DirProjects))
257-
self.remove()
258-
AppLog.info('clone into dir: {}'.format(
259-
Constants.DirProjects))
260-
self.clone()
275+
self._clone()
261276
else:
262277
# 重置并pull
263278
AppLog.info('reset dir: {}'.format(Constants.DirProjects))
279+
AppLog.info('reset target: {}'.format(repo.head.target))
280+
repo.state_cleanup()
264281
repo.reset(repo.head.target, pygit2.GIT_RESET_HARD)
265282
Signals.progressUpdated.emit(5, 100)
266283
AppLog.info('pull into dir: {}'.format(
@@ -377,7 +394,7 @@ def run(self):
377394
QThread.msleep(1000)
378395
show = False
379396
Signals.updateTextChanged.emit(str(Version.version),
380-
str(version), text)
397+
str(version), text)
381398
self.download(Constants.UpgradeFile.format(version),
382399
url_zip.format(version))
383400
Signals.updateFinished.emit(self.tr('update completed'))

‎Widgets/TreeView.py

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -105,31 +105,37 @@ def initCatalog(self):
105105
if not os.path.exists(Constants.DirProjects):
106106
return
107107
pitem = self._dmodel.invisibleRootItem()
108-
# 只遍历根目录
109-
for name in os.listdir(Constants.DirProjects):
110-
file = os.path.join(Constants.DirProjects, name).replace('\\', '/')
111-
if os.path.isfile(file): # 跳过文件
112-
continue
113-
if name.startswith(
114-
'.') or name == 'Donate' or name == 'Test': # 不显示.开头的文件夹
115-
continue
116-
items = self.findItems(name)
117-
if items:
118-
item = items[0]
119-
else:
120-
item = QStandardItem(name)
121-
# 添加自定义的数据
122-
# 用于绘制进度条的item标识
123-
item.setData(True, Constants.RoleRoot)
124-
# 目录或者文件的绝对路径
125-
item.setData(
126-
os.path.abspath(os.path.join(Constants.DirProjects, name)),
127-
Constants.RolePath)
128-
pitem.appendRow(item)
129-
# 遍历子目录
130-
self.listSubDir(item, file)
131-
# 排序
132-
self._fmodel.sort(0, Qt.AscendingOrder)
108+
try:
109+
# 只遍历根目录
110+
for name in os.listdir(Constants.DirProjects):
111+
file = os.path.join(Constants.DirProjects,
112+
name).replace('\\', '/')
113+
if os.path.isfile(file): # 跳过文件
114+
continue
115+
if name.startswith(
116+
'.'
117+
) or name == 'Donate' or name == 'Test': # 不显示.开头的文件夹
118+
continue
119+
items = self.findItems(name)
120+
if items:
121+
item = items[0]
122+
else:
123+
item = QStandardItem(name)
124+
# 添加自定义的数据
125+
# 用于绘制进度条的item标识
126+
item.setData(True, Constants.RoleRoot)
127+
# 目录或者文件的绝对路径
128+
item.setData(
129+
os.path.abspath(
130+
os.path.join(Constants.DirProjects, name)),
131+
Constants.RolePath)
132+
pitem.appendRow(item)
133+
# 遍历子目录
134+
self.listSubDir(item, file)
135+
# 排序
136+
self._fmodel.sort(0, Qt.AscendingOrder)
137+
except Exception as e:
138+
AppLog.error(str(e))
133139

134140
def onClicked(self, modelIndex):
135141
"""Item单击

‎requirements.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
requests
2-
markdown2
3-
pygments
4-
pygit2==0.27.2
5-
PyQt5==5.10.1
6-
PyQtWebKit==5.10.1
7-
PyQt3D==5.10.1
8-
PyQtChart==5.10.1
9-
PyQtDataVisualization==5.10.1
10-
PyQtPurchasing==5.10.1
2+
pygit2==1.9.2
3+
PyQt5-sip==12.8.0
4+
PyQt5==5.15.2
5+
PyQt3D==5.15.2
6+
PyQtChart==5.15.2
7+
PyQtDataVisualization==5.15.2
8+
PyQtPurchasing==5.15.2
9+
PyQtWebEngine==5.15.2
10+
PyQtWebKit==5.15.2

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /