Apidocjs

@apiIgnore 跳过在写的部份(未完成)

@apiSuccess 返回 Response 参数解释

  • 嵌套 json 解释

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    
    def crop_image():
        """
        @api {post} /crop_image             Request to crop image for a pdf
        @apiName                            CropImagePost
        @apiGroup                           Cropper
        @apiVersion                         0.1.0
        @apiSuccess {String} code           Status code.
        @apiSuccess {Object[]} data         Tasks' result list.
    
        @apiSuccess {Number} data.code         Status code of the Task.
        @apiSuccess {String} data.coordinates  Coordinate group of the Task.
    
        @apiSuccessExample {json} Success Response json:
        {
          "code": 2000,
          "data": [
            {
              "code": 2000,
              "coordinates": "1,166.6,539.87,16.5022,9.1575;1,166.6,539.87,16.5022,9.1575",
            }
          ],
        }
    
        """
        pass

一个函数 多个 method

  • 注意

Pyside ---- Qt official python api

环境配置错误

设置 QObject 属性

  • 动态属性

    • setter & getter

      • obj.setProperty("propName", "value")
      • obj.property("propName")
    • 遍历

      • obj.dynamicPropertyNames()
1
2
3
4
5
6
obj.setProperty("Full name", "Summer Festival")
obj.setProperty("Age", 16)
obj.setProperty("Gender", "female")
names = obj.dynamicPropertyNames()
for name in names:
    print(str(name, encoding="utf-8"))

使用 CSS

  • 方法

subprocess ---- python shell tool

subprocess.run

  • 参数

    • check=True

      • 自动跳出 subprocess.CalledProcessError 异常
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class RunCommand:
    """Run the command and check if the command is success
    """
    def __init__(self, command: str, check=True, capture_output=True):
        self.command = command
        self.logger = logging.getLogger(self.__class__.__name__)
        # self.logger = logging.getLogger(str(self.__class__))
        self.success = True
        self.returncode = None
        self.check = check
        self.capture_output = capture_output

    def run(self) -> bool:
            """Run the command in the shell.
            """
        try:
            self.logger.info('try to run command: %s', self.command)
            ret = subprocess.run(shlex.split(self.command),
                         check=self.check,
                         capture_output=self.capture_output
                         )
            self.returncode = ret.returncode
        except subprocess.CalledProcessError as e:
            self.logger.info('Failed to call command: %s', self.command)
            self.logger.exception(e)
            self.success = False
        return self.success

subprocess.Popen

  • 与命令交互,可以取出命令输出内容
  • 调用方式

Awk

Cheat Sheet

  • 指定分隔符

    1
    
    awk -F "," '{print Awk}' ./filename.txt
  • 多个 field 输出,使用 ","

    1
    2
    3
    4
    5
    6
    7
    
    # 输入
    #figure-extract                              cuda12.2-1-move-app-v1               a74c57ab7c82   3 days ago      7.16GB
    #table-extract                               cuda12.2-1-move-app                  358de070777c   3 days ago      16.4GB
    awk '{print $1,":",$2}'
    # 输出
    # figure-extract:cuda12.2-1-move-app-v1
    # table-extract:cuda12.2-1-move-app

分隔符: -F ","

设置变量: -v

  • -v FS="\t"

与 unexpand 连用

  • unexpand 把空格转化成 tab(\t)字符

if 语句

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
$ awk '{
  if ([]:  >=35 &&  >= 35 &&  >= 35)
      print ,"=>","Pass";
  else
      print ,"=>","Fail";
  }' student-marks
Jones 2143 78 84 77 => Pass
Gondrol 2321 56 58 45 => Pass
RinRao 2122 38 37 => Fail
Edwin 2537 87 97 95 => Pass
Dayan 2415 30 47 => Fail

Curl

POST 请求

  • 参考

  • 参数

    • -X, –request

      • 可选值: POST, GET, …
    • -F, –form

      • 背后机制:设置 Content-Type:multipart/format
      • 格式: -F 'key=value'
      • 用途: 发送请求字段
    • -d, –data

      • 背后机制:设置 Content-Type=application/x-www-form-urlencoded
      • 格式:
    • -d 'key=value' -d 'key01=value01' –> 一次制定一个字段
    • -d 'key01=value01&key02=value02' –> 多个字段
    • -H, –header