调试记录-repo同步代码出错

问题描述

在RK项目开发过程中,官方提供的SDK是用repo管理的,拿到SDK压缩包之后第一步是先解压,然后就是把代码checkout出来,再做同步,相关的指令是:

tar xzf xxx.tar.gz
.repo/repo/repo sync -l
.repo/repo/repo sync -c

但是,可能是服务器环境的问题,最近遇到repo sync的时候出错,报错log是:

$ repo sync -l
Traceback (most recent call last):
  File "/home/xxx/rk3399/linux_release_v2.9.0/.repo/repo/main.py", line 56, in <module>
    from subcmds.version import Version
  File "/home/xxx/rk3399/linux_release_v2.9.0/.repo/repo/subcmds/__init__.py", line 34, in <module>
    mod = __import__(__name__,
  File "/home/xxx/rk3399/linux_release_v2.9.0/.repo/repo/subcmds/help.py", line 20, in <module>
    from formatter import AbstractFormatter, DumbWriter
ModuleNotFoundError: No module named 'formatter'

解决方法

经过Google,找到解决方法如下:

diff --git a/subcmds/help.py b/subcmds/help.py
index 9ba9e70..6a767e6 100644
--- a/subcmds/help.py
+++ b/subcmds/help.py
@@ -14,7 +14,7 @@
 
 import re
 import sys
-from formatter import AbstractFormatter, DumbWriter
+import textwrap
 
 from subcmds import all_commands
 from color import Coloring
@@ -84,8 +84,7 @@
       def __init__(self, gc):
         Coloring.__init__(self, gc, 'help')
         self.heading = self.printer('heading', attr='bold')
-
-        self.wrap = AbstractFormatter(DumbWriter())
+        self._first = True
 
       def _PrintSection(self, heading, bodyAttr):
         try:
@@ -95,7 +94,9 @@
         if body == '' or body is None:
           return
 
-        self.nl()
+        if not self._first:
+          self.nl()
+        self._first = False
 
         self.heading('%s%s', header_prefix, heading)
         self.nl()
@@ -105,7 +106,8 @@
         body = body.strip()
         body = body.replace('%prog', me)
 
-        asciidoc_hdr = re.compile(r'^\n?#+ (.+)$')
+        # Extract the title, but skip any trailing {#anchors}.
+        asciidoc_hdr = re.compile(r'^\n?#+ ([^{]+)(\{#.+\})?$')
         for para in body.split("\n\n"):
           if para.startswith(' '):
             self.write('%s', para)
@@ -120,9 +122,12 @@
             self.nl()
             continue
 
-          self.wrap.add_flowing_data(para)
-          self.wrap.end_paragraph(1)
-        self.wrap.end_paragraph(0)
+          lines = textwrap.wrap(para.replace('  ', ' '), width=80,
+                                break_long_words=False, break_on_hyphens=False)
+          for line in lines:
+            self.write('%s', line)
+            self.nl()
+          self.nl()
 
     out = _Out(self.client.globalConfig)
     out._PrintSection('Summary', 'helpSummary')

补丁来源:
https://gerrit-review.googlesource.com/c/git-repo/+/303282

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值