RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-441592

Miekrif's questions

Martin Hope
Miekrif
Asked: 2023-12-05 22:02:29 +0000 UTC

如何在 Apach Cordova 上设置 .aab 测试

  • 6

该项目的开发人员在 Android 版 Apache Cordova 中编写了一个应用程序。在 alpha 阶段,我们收集了当前的 *.apk 文件,现在我们生成并签名 .aab 以上传到商店,但出现了 Google Play Console 过于频繁的问题拒绝它,因为

“全家人应用的要求。应用稳定性。”

如果你测试一下.apk文件,我们在实体手机上测试过一切都很好,现在怀疑是.aab损坏了,如何检查呢?

我正在参与一个担任 DevOps 角色的项目。我们的 CI/CD 如下所示

build_image_aab:
  stage: build_image
  image: docker:19.03.12
  services:
    - docker:19.03.12-dind
  script:
    - mv $ENV .env
    - cp -r /home/gitlab-runner/signature $(pwd)/signature
    - sudo docker build -t krif/chi-aab:latest -f release/Dockerfile.aab .
    - container_id=$(sudo docker create rif/chi-aab:latest)
    - sudo docker cp $container_id:/app/mobileapp/platforms/android/app/build/outputs/bundle/release/app-release.aab ./chary.aab
    - sudo docker rm $container_id
    - sudo docker image prune -f
  artifacts:
    paths:
      - ./chary.aab
      - ./signature
  tags:
    - signature
    #- for_build_images
  only:
    refs:
      - main
      - release


signature_aab:
  stage: signature
  image: androidsdk/android-31  # Используем образ с Android SDK 30
  script:
    - java -version
    - apksigner sign --ks signatureapp --ks-key-alias chi_app --ks-pass pass:$store_pass --out siry.aab --min-sdk-version 21 chry.aab
  artifacts:
    paths:
      - ./siry.aab
  tags:
    - for_build_images
  needs:
    - build_image_aab
android
  • 1 个回答
  • 18 Views
Martin Hope
Miekrif
Asked: 2023-03-10 18:42:43 +0000 UTC

如何将配置文件扔到容器中

  • 5

我正在 GO 上构建我的应用程序,但由于某种原因没有上传配置文件

FROM golang:latest

WORKDIR app

COPY task-manager .

RUN go mod download

RUN go build TaskManager/cmd/main

VOLUME /root/envs_dev/.env /go/app/.env

CMD ["./main"]

文件已经到位,他亲自将其转移到那里并检查了

root@test-asup-dev-devops:~/envs_dev# ls -lha
total 12K
drwxr-xr-x 2 root root 4.0K Mar  9 14:35 .
drwx------ 7 root root 4.0K Mar  9 15:15 ..
-rw-r--r-- 1 root root  378 Mar  9 14:35 .env

容器产生以下日志:

panic: config file parsing error: read /go/app/.env: is a directory

goroutine 1 [running]:
TaskManager/pkg/configuration.init.0()
    /go/app/pkg/configuration/configuration.go:41 +0x92
docker
  • 1 个回答
  • 15 Views
Martin Hope
Miekrif
Asked: 2022-08-30 15:47:17 +0000 UTC

使用 psycopg2 从 postgresql 导出表

  • -1

有一个写数据到表的大脚本,需要从数据库中导出过时的数据进行存储

def export_data(cursor, name, connection):
    try:
        print(f''' COPY '{name}' TO '/tmp/databases/{name}/{name}_{datetime.now().strftime("%d_%m_%y")}.csv' WITH (FORMAT CSV, HEADER) ''')
        insert_table_query = f''' COPY '{name}' TO '/tmp/databases/{name}/{name}_{datetime.now().strftime("%d_%m_%y")}.csv' WITH (FORMAT CSV, HEADER) '''
        cursor.execute(insert_table_query)
        connection.commit()
    except Exception and errors as e:
        print(e)

错误

Connection to PostgreSQL DB successful
 COPY 'sprint' TO '/tmp/databases/sprint/sprint_30_08_22.csv' WITH (FORMAT CSV, HEADER) 
catching classes that do not inherit from BaseException is not allowed

不完全清楚如何实现表暴露

python
  • 1 个回答
  • 49 Views
Martin Hope
Miekrif
Asked: 2022-09-04 17:13:05 +0000 UTC

在 postgresql psycopg2 中用点写入数据

  • 0

有一段代码,根据模块中包含的数据类型,写入不同的区间。但是在写入文件名的时候会出现一个问题,因为它们有“.”这样的值,一个记录文件的例子:

__Release_Notes/Q3.2/Poy/3154__Data_1

但在一个名为:

__Release_Notes/Q3.1/C394

他抱怨

psycopg2.errors.SyntaxError: syntax error at or near ".1"
LINE 4: ...                               (__Release_Notes/Q3.1/

代码本身看起来像这样

# SQL-запрос для создания новой таблицы
def create_table(time, cursor, count_time):
    create_table_query = f'''CREATE TABLE IF NOT EXISTS {time}
                              (
                              metada TEXT PRIMARY KEY NOT NULL,
                              {count_time}   INT 
                              ); '''
    cursor.execute(create_table_query)

    # Выполнение команды: это создает новую таблицу


def inster_into_table_one_day(cursor, Changedata, time):
     #dfirst need del 
    ID = 1
    for ticket, day in Changedata.items():
        if ticket == 'Merge_or_Fix':
            continue
        ID += 1
        insert_table_query = f'''INSERT INTO {time}
                                  (metada, one_day)
                                  VALUES
                                  ('{ticket}', {day})
                                   ; '''
        cursor.execute(insert_table_query)
python
  • 1 个回答
  • 18 Views
Martin Hope
Miekrif
Asked: 2022-09-06 14:56:02 +0000 UTC

将代码 200 发送到服务器而不使用返回

  • -1

有一个用于接收 POST 的网络服务器,该服务器是一个巨大的管道的一部分,该管道运行 5 分钟以上,具体取决于传入的 POST 因此,FLASK 返回一个 500 代码,我该如何解决这个问题?

代码烧瓶

@app.route("/gitlab-webhook", methods=['POST'])
def githubWebhook():
    def load_secret(TOKEN, key):
        try:
            # slack_message_pipe(step=f'I LOAD JSON')
            print(TOKEN, ' !!! ', key)
            if TOKEN == key:
                return 200
            else:
                return 404
        except Exception as e:
            slack_message_pipe(step=e)
    try:
        content = request.json
        data = request.headers
        print(type(data))
        key = data['X-Gitlab-Token']
        load_secret(TOKEN, key)
        commits_list = content['commits']
        json_dump_for_proj(data=commits_list)
    except Exception as e:
        slack_message_pipe(step=e)


if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8889)

错误:

ERROR in app: Exception on /gitlab-webhook [POST]
Traceback (most recent call last):
File "python3.8/site-packages/flask/app.py", line 2070, in wsgi_app
response = self.full_dispatch_request()
File "python3.8/site-packages/flask/app.py", line 1516, in full_dispatch_request
return self.finalize_request(rv)
File "/python3.8/site-packages/flask/app.py", line 1535, in finalize_request
response = self.make_response(rv)
File "/python3.8/site-packages/flask/app.py", line 1698, in make_response
raise TypeError(
TypeError: The view function for 'githubWebhook' did not return a valid response. The function either returned None or ended without a return statement.
"POST /gitlab-webhook HTTP/1.1" 500 -

阅读错误后,想法是使用make_response(),但我还没有从阅读材料中找到有关此主题的示例或任何内容

python python-3.x
  • 1 个回答
  • 31 Views
Martin Hope
Miekrif
Asked: 2022-06-20 23:59:43 +0000 UTC

如何在python循环中找出文件是否是新文件

  • 0

python中有一个循环:

 for i in file:
            if os.path.exists(MY_PATH_GIT+i):
                #copy for anasys on linux
                os.system(f'cp "{MY_PATH_GIT+i}" {place+"/"}')
                #On this step we sort deleted\not deleted file for deploy and pmd analys
                file_true.append(MY_PATH_GIT + i)
            else:
                print('\n========= deleted ' + MY_PATH_GIT + i + ' =========\n')  # checking the bot

它检查文件是否存在以便将其添加到列表中,然后将其替换在行中进行验证,但是有一个文件类型只允许在它是新的时进行验证,我怎样才能获得这样的信息?

python os
  • 2 个回答
  • 33 Views
Martin Hope
Miekrif
Asked: 2022-08-29 22:47:45 +0000 UTC

在 venv 的 systemd 中妖魔化一个 python 机器人

  • 0

大家好,请帮助我提供以下 debian 可用目录 /etc/systemd/system 中的c venv /home/vladsu/.virtualenvs/vlad/bin/activate c bot服务文件/home/vladsu/SM_8ject/SM-8/SM_8.py

[Unit]
Description=SM_803
After=network.target

[Service]
User=root
Group=root
WorkingDirectory=/home/vladsu/SM_8ject/SM-8
ExecStart=/home/vladsu/.virtualenvs/vlad/bin/python3 /home/vladsu/SM_8ject/SM-8/SM_8.py
Restart=always
RestartSec=240
[Install]
WantedBy=multi-user.target

但由于某种原因,机器人在其目录中看不到依赖项以及如何为日志指定文件?

python
  • 1 个回答
  • 10 Views
Martin Hope
Miekrif
Asked: 2022-08-14 23:31:23 +0000 UTC

aiogram,通过 FSM 发送照片时出错

  • 0

我正在尝试设置发送照片事件的处理以将其发送到聊天室。想法是这样的,当收到照片时,为它填写标题并将其发送到超级组。

# Обработка присылаемого фото
class WaitPhoto(StatesGroup):
    waiting_photo = State()
    # waiting_photo_commit = State()


@dp.message_handler(content_types=["photo"])
async def photo_message(message: types.Message, state: FSMContext):
    file_id = message.photo[-1].file_id  # file ID загруженной фотографии
    await state.update_data(file_id=file_id)
    # print(type(file_id))
    # file_id1 = pic.photo
    button_phone = types.KeyboardButton(text="Делись!", request_contact=True)
    keyboard = types.ReplyKeyboardMarkup(row_width=1, resize_keyboard=True)
    keyboard.add(button_phone)
    await message.answer(text="Для того, чтобы понять кто прислал чек, мне нужен твой номер", reply_markup=keyboard)
    # await WaitPhoto.waiting_photo.set()


@dp.message_handler(content_types=["contact"])
async def contact_photo(pic2: types.Message, state: FSMContext):
    data = pic2.contact
    phone = str(data)
    phone = re.findall('"phone_number": "[0-9]+"', phone)
    phone = str(phone).replace('"phone_number": "', '+')
    # global phone = phone
    phone = phone.replace('"', '')
    await state.update_data(phone=phone)
    userbtn = str(data)
    userbtn = re.findall('"user_id": [0-9]+', userbtn)
    userbtn = str(userbtn).replace('"user_id": ', '')
    add_to_dict(userbtn, phone)
    message = [types.InlineKeyboardButton(text="Чайная История на Пушке", callback_data='Чайная История на Пушке фото'),
               types.InlineKeyboardButton(text='Чайная История на Театралке',
                                          callback_data='Чайная История на Театралке фото')]
    keyboard = types.InlineKeyboardMarkup(row_width=1, resize_keyboard=True)
    keyboard.add(*message)
    # await WaitPhoto.next()
    await bot.send_message(pic2.chat.id, "Выбери свою точку", reply_markup=keyboard)
#
#
@dp.callback_query_handler(text='Чайная История на Пушке фото')
async def send_long_message_from(message: types.Message, state: FSMContext):
    # inf = pic2
    inf = 1
    file_id, phone = await state.get_data()
    await bot.send_photo(chat_id=chekichat, photo= file_id)
    await bot.send_message(chat_id=chekichat, text=f"Хей🖖,сегодня {a}, отправил его {phone} и это {inf}")
    await state.finish()
python
  • 1 个回答
  • 10 Views
Martin Hope
Miekrif
Asked: 2022-08-10 15:37:03 +0000 UTC

使用 Python 套接字进行异常处理或故障排除

  • 0

我在 pyhon3 上有一个套接字服务器,由于行走机器人会敲击所有打开的端口,因此具有一定的安全性。脚本工作正常,但由于 Dos,它会因错误而崩溃

错误代码:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File "SM_803GIT.py", line 94, in <module>
    start_my_server()   File "SM_803GIT.py", line 79, in start_my_server
    load_secret(secret_token, data)   File "SM_803GIT.py", line 43, in load_secret
    accept(key)   File "SM_803GIT.py", line 49, in accept
    try_to_verification(key)   File "SM_803GIT.py", line 60, in try_to_verification
    next_step()   File "SM_803GIT.py", line 89, in next_step
    start_my_server()   File "SM_803GIT.py", line 79, in start_my_server
    load_secret(secret_token, data)   File "SM_803GIT.py", line 43, in load_secret
    accept(key)   File "SM_803GIT.py", line 49, in accept
    try_to_verification(key)   File "SM_803GIT.py", line 60, in try_to_verification
    next_step()   File "SM_803GIT.py", line 89, in next_step
    start_my_server()   File "SM_803GIT.py", line 79, in start_my_server
    load_secret(secret_token, data)   File "SM_803GIT.py", line 43, in load_secret
    accept(key)   File "SM_803GIT.py", line 49, in accept
    try_to_verification(key)   File "SM_803GIT.py", line 60, in try_to_verification
    next_step()   File "SM_803GIT.py", line 89, in next_step
    start_my_server()   File "SM_803GIT.py", line 79, in start_my_server
    load_secret(secret_token, data)   File "SM_803GIT.py", line 43, in load_secret
    accept(key)   File "SM_803GIT.py", line 49, in accept
    try_to_verification(key)   File "SM_803GIT.py", line 60, in try_to_verification
    next_step()   File "SM_803GIT.py", line 89, in next_step
    start_my_server()   File "SM_803GIT.py", line 79, in start_my_server
    load_secret(secret_token, data)   File "SM_803GIT.py", line 43, in load_secret
    accept(key)   File "SM_803GIT.py", line 49, in accept
    try_to_verification(key)   File "SM_803GIT.py", line 60, in try_to_verification
    next_step()   File "SM_803GIT.py", line 89, in next_step
    start_my_server()   File "SM_803GIT.py", line 79, in start_my_server
    load_secret(secret_token, data)   File "SM_803GIT.py", line 43, in load_secret
    accept(key)   File "SM_803GIT.py", line 49, in accept
    try_to_verification(key)   File "SM_803GIT.py", line 60, in try_to_verification
    next_step()   File "SM_803GIT.py", line 89, in next_step
    start_my_server()   File "SM_803GIT.py", line 79, in start_my_server
    load_secret(secret_token, data)   File "SM_803GIT.py", line 43, in load_secret
    accept(key)   File "SM_803GIT.py", line 49, in accept
    try_to_verification(key)   File "SM_803GIT.py", line 60, in try_to_verification
    next_step()   File "SM_803GIT.py", line 89, in next_step
    start_my_server()   File "SM_803GIT.py", line 79, in start_my_server
    load_secret(secret_token, data)   File "SM_803GIT.py", line 43, in load_secret
    accept(key)   File "SM_803GIT.py", line 49, in accept
    try_to_verification(key)   File "SM_803GIT.py", line 60, in try_to_verification
    next_step()   File "SM_803GIT.py", line 89, in next_step
    start_my_server()   File "SM_803GIT.py", line 81, in start_my_server
    start_my_server()   File "SM_803GIT.py", line 76, in start_my_server
    data = client_socket.recv(1048576).decode('utf-8') UnicodeDecodeError: 'utf-8' codec can't decode byte 0xee in position 4: invalid continuation byte

我该如何处理这种情况,或者只是从一个 ip 代码示例中跳过大量请求:

import os
import socket
from pathlib import Path
from dotenv import load_dotenv
import json
import time
import re

#Init .env
env_path = Path('.') / '.env'
load_dotenv(dotenv_path=env_path)

#init
secret_token = os.environ['secret_token']

#time
seconds = time.time()
local_time = time.ctime(seconds)

#HDRS
HDRS = 'HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=utf-8\r\n\r\n'
HDRS_404 = 'HTTP/1.1 404 OK\r\nContent-Type: text/html; charset=utf-8\r\n\r\n'

socket_server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket_server.bind(('ip', port))
socket_server.listen(32768)
#create webserver socket
def start_my_server():
    # print('Working...')
    # client_socket, address = socket_server.accept()
    # print('loop', address)
    #
    # data = client_socket.recv(1048576).decode('utf-8')
    def load_secret(secret_token, data):
        key = str(data)
        key = re.findall(f'X-Gitlab-Token:.............', key)
        key = str(key).replace("['X-Gitlab-Token: ",'')
        key = str(key).replace("']", '')
        # print(key, 'load_secret')
        # print(secret_token, 'load_secret')
        if secret_token == key:
            accept(key)
        else:
            fail_verifivcation()
        # return key
    def accept(key):
        print('Find')
        try_to_verification(key)

    def try_to_verification(key):
        print(key, 'key try_to_verification')
        # print(data,'\n', client_socket,'\n', address,'\n', 'ПРОВЕРКА')
        with open(f'data("{local_time}").json', 'w') as output_file:
            json.dump(data, output_file)
        client_socket.send(HDRS.encode('utf-8'))
        client_socket.shutdown(socket.SHUT_WR)
        # socket_server.close()
        # return init_next()
        next_step()
    def fail_verifivcation():
        print('Not find')
        client_socket.shutdown(socket.SHUT_WR)
        addresses = open('ipPOST', 'a')
        addresses.write(str(address) + f'{local_time}\n')
        addresses.close()
        # init_next()
    try:
        while True:
            print('Working...')
            client_socket, address = socket_server.accept()
            print('loop', address)
            addresses = open('ipPOST', 'a')
            addresses.write(str(address) + f'{local_time}\n')
            # addresses.close()
            data = client_socket.recv(1048576).decode('utf-8')
            # content = load_page_from_get_request(data)
            # return data, client_socket, address
            load_secret(secret_token, data)
    except socket.error:
        start_my_server()
    # load_secret(secret_token, data)
    # init_next()
    # return init_next()

def next_step():
    print('next step')
    # return  init_next()
    start_my_server()

print('loop script')
if __name__ == '__main__':
    print('name = main')
    start_my_server()
    # load_secret()
    next_step()
python
  • 1 个回答
  • 10 Views
Martin Hope
Miekrif
Asked: 2022-08-04 19:41:56 +0000 UTC

接受一个 POST json 后通信中断

  • 1

任务是这样的,你需要在http://ip:port处捕获会不断从主机到达的json但是在接收到第一个json之后,脚本没有写就崩溃了,如何捕获错误或了解错误是什么?

import os
import socket
from pathlib import Path
from dotenv import load_dotenv
import json

#Init .env
env_path = Path('.') / '.env'
load_dotenv(dotenv_path=env_path)
#create webserver socket
def start_my_server():
    socket_server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    socket_server.bind(('ip', port))
    socket_server.listen(32768)
    print('Working...')
    global data
    global HDRS
    while True:
        client_socket, address = socket_server.accept()
        data = client_socket.recv(32768).decode('utf-8')
        #print(data, '-'*20)
        # content = 'Well done'.encode('utf-8')
        HDRS = 'HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=utf-8\r\n\r\n'
        # content = load_page_from_get_request(data)
        # client_socket.send(HDRS.encode('utf-8'))
        #a = client_socket.send(HDRS.encode('utf-8'))
        client_socket.send(HDRS.encode('utf-8'))
        #print(a, '+'*20)
        client_socket.shutdown(socket.SHUT_WR)
    # print('end')
    # socket_server.close()

def load_page_from_get_request(request_data):
    with open('data.json', 'w') as output_file:
        json.dump(data, output_file)
    # try

if __name__ == '__main__':
    start_my_server()
python
  • 1 个回答
  • 10 Views
Martin Hope
Miekrif
Asked: 2022-06-28 17:30:35 +0000 UTC

正确计算值

  • 0

有一个从 json 数据生成字典的代码

json数据示例: 链接

代码本身

 import os
        import re
        import json
        import collections
        
     

   # Initialization collection for all lvl
    rule0 = collections.defaultdict(int) #
    rule1 = collections.defaultdict(int) #
    rule2 = collections.defaultdict(int) #
    rule3 = collections.defaultdict(int) #
    rule4 = collections.defaultdict(int) #
    rule5 = collections.defaultdict(int) #
    
    MY_RULE = {}
    
    # run comandline for create json
    # MY_PAT = os.system(r'pmd -d C:\Users\vsi\int\sfdevops_metrics\.project\na_gold\force-app\main\default\classes -R C:\Users\vsi\int\sfdevops_metrics\.project\na_gold\__PMD\GOLD_ruleset.xml -f json > C:\Users\vsi\int\sfdevops_metrics\.project\SM-774\output.json')
    
    #open json
    with open(r'C:\Users\vsi\int\sfdevops_metrics\.project\SM-774\output.json') as json_file:
        MY_PATH = json.load(json_file, object_hook=None)
    
    #refactor json
    for values in MY_PATH['files']:
        for i in values['violations']:
            if i['priority'] == 1:
                rule1[i['priority']] += 1
            elif i.get('priority') == 2:
                rule2[i['priority']] += 1
            elif i.get('priority') == 3:
                rule3[i['priority']] += 1
            elif i.get('priority') == 4:
                rule4[i['priority']] += 1
            elif i.get('priority') == 5:
                rule5[i['priority']] += 1
            rule0[i['priority']] += 1
        for key1 in values.items():
            key1 = str(key1)
            key1 = re.findall(r'C:.*', key1)
            key1 = str(key1)
            key1 = key1.replace(r'"C:\\\\Users\\\\vsi\\\\int\\\\sfdevops_metrics\\\\.project\\\\na_gold\\\\force-app\\\\main\\\\default\\\\classes\\\\', '')
            key1 = key1.replace("')\"", '')
            rule6 = str(rule0).replace("defaultdict(<class 'int'>, ", '')
            rule7 = str(rule1).replace("defaultdict(<class 'int'>, ", '')
            rule8 = str(rule2).replace("defaultdict(<class 'int'>, ", '')
            rule9 = str(rule3).replace("defaultdict(<class 'int'>, ", '')
            rule10 = str(rule4).replace("defaultdict(<class 'int'>, ", '')
            rule11 = str(rule5).replace("defaultdict(<class 'int'>, ", '')
        # MY_RULE[a] = values
    
            MY_RULE[key1] = MY_RULE.get(key1, []) + [( rule7, rule8, rule9, rule10, rule11)]
    del MY_RULE['[]']
    
            # print(a)
    # for i in values['violations']:
    #     print(i[''])
    
        # print(rule0)
    print(MY_RULE)

我打算计算每个文件的优先级数,但最后它会计算所有文件的所有优先级并根据标准数对它们进行相应的求和,最后结果是 {4: 3965, 2: 6572, 3: 1285, 1: 129, 5:65} 如何更改代码以便仅在一个文件的框架内考虑优先级

python
  • 1 个回答
  • 10 Views
Martin Hope
Miekrif
Asked: 2022-06-10 22:37:13 +0000 UTC

如何使用 GitPython 从 Git 获取有关特定时间段内元数据更改的信息?

  • 0

需要从项目中提取元数据变化信息到git(有本地副本),即:某分支上2周内对文件(代码、方法)的提交次数

import os
import time
import git
import datetime
Changedata = {}
MY_PATH = os.chdir(r'C:\Users\vsi\int\sfdevops_metrics\.project\na_gold')
repo = git.Repo(MY_PATH)
commits = list(repo.iter_commits("Staging", datetime=))

从代码来看,只有萝卜的初始化和时间排序的制作

python
  • 1 个回答
  • 10 Views
Martin Hope
Miekrif
Asked: 2022-05-24 15:08:43 +0000 UTC

如何使用 pymysql 正确地将 json 写入 mysql?

  • 0

亲爱的专家,有一个带有mysql的容器和一个包含来自git的数据的字典,该字典被转换为json

我只在python中待了一个星期,我正在等待严厉但有建设性的批评并要求您提供链接,因为我在互联网上挖出的所有内容都没有给我一寸解决缺少此信息的问题

import mysql.connector
import json
import mysql
import pymysql
import pymysql.cursors
from PythonGIT import Lastwords

#make json data from Lastwords
json_send = json.dumps(Lastwords, indent=4)
#print(json_send)
#make connect to DB
def create_connection(host_name, host_port, user_name, user_password, db_name):
    connection = None
    try:
        connection = mysql.connector.connect(
            host=host_name,
            port=host_port,
            user=user_name,
            passwd=user_password,
            database=db_name
        )
        print("Connection to MySQL DB successful")
    except Error as e:
        print(f"The error '{e}' occurred")

    return connection
connection = create_connection("localhost", 3306, "root", "My:S3cr3t/", "jiragit")
cursor = connection.cursor(pymysql.cursors.DictCursor)
#send json to DB
# json_send
# sql = ""
with cursor:
    sql = "CREATE TABLE IF NOT EXISTS jiragit ( JiraTicket TEXT, EVENT TEXT) VALUES (%s,%s)"
    cursor.execute(sql, json_send)




connection.commit()
#Close connections
connection.close()
print("Connect close")

json

"MID-4151": [
        [
            "7e5ac616df12ed6fb344c8cf1817e5a9f4ee6c34",
            "kurbat_kanstantsin"
        ],
        [
            "1f201a2c10e12f3781afb7cf52e0b24530ee22da",
            "kurbat_kanstantsin"
        ],
        [
            "e473e1b77857fa2ef6e34c7f4117e48d1149cb4c",
            "kkurbat"
        ],
        [
            "41085f9b17a02b1773da26291573be51dd7c44fc",
            "kkurbat"
        ]
    ],
    "IN-2558": [
        [
            "18a382da0903bc4c1aa8dbdc09423e6120293409",
            "artem"
        ],
        [
            "f28fee874a30b854536ace422f401181b70d6f28",
            "artem"
        ],
        [
            "c5f4b78781e1495c21fc02bf5a696835a1eab431",
            "artem"
        ],
        [
            "313b300d2e4ae3eb17f62cf2acd6d00713df0ca9",
            "artem"
        ],
        [
            "2a7a1a6517ffb71f5a0d1da3cf18bd6c511102d0",
            "artem"
        ]
    ],

听写

{'CE-2019': [('a3873de1b37c14ea2d9379387026da6188cdd5d2', 'Ivan Vdovin'), ('327f430f39dd2db0c4ad9bb8fa599d7be7b1b4df', 'dmitrykoptik')], 'Merge_or_Fix': [('467f483d9fac6f2a587065ad6c3eeb4557b430bc', 'Stanislav Dudkov aka D2269'), ('1565ec5429da1156b593ea16658409288176edbe', 'Petr Sabaleuski'), ('2bda4e434cbe9271e9719feb16d27b04058d689f', 'Petr Sabaleuski'), ('caf6ee5460645a2691aeb03693a94327fd6833e7', 'Alex_Odinokov'),
python
  • 1 个回答
  • 10 Views
Martin Hope
Miekrif
Asked: 2022-05-21 21:09:18 +0000 UTC

无法将键从字典转换为列表,以免覆盖重复数据

  • 0

大家好,我有以下代码:

Lastwords = {}     
repo = git.Repo(MY_PATH)
commits = list(repo.iter_commits("master", max_count=499))
    

for i in range(0,499):
    commits1 = commits[i]
    author = commits[i].author
    message = commits[i].message
    message1 = commits[i].message.join(re.findall(r'[A-Z]{2,3}-[0-9]{3,4}',message))

    Lastwords[message1] = commits1, author

message1 字段包含有关可以重复的 jiratickets 的信息。我想到了将键设为列表,但无论我如何尝试:

list(Lastwords.keys())

Lastwords[list(message1)] = commits1, author

我不擅长,我在python只有一个星期我要求你严格和建设性地判断。所有有生产力的工作日!

python
  • 2 个回答
  • 10 Views
Martin Hope
Miekrif
Asked: 2022-07-07 16:22:58 +0000 UTC

用于复制特定扩展名的文件并将大写更改为小写的 Bash 脚本

  • 1

bash脚本从目录(包括子文件夹)复制一定扩展名的文件而不保存结构有Ubuntu18,将文件保存为Axxx.xlsx格式我写了如下脚本

find -name «*.xlsx» | tr [:upper:] [:lower:] | cp /home/vskibenko/tmp/.

但是处理的不是很好。

该脚本的本质是“将文件从一个文件夹及其子文件夹复制到另一个目录,将名称更改为小写”

linux
  • 2 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5