format all code
This commit is contained in:
parent
f2c1692f5a
commit
cf933684f3
6 changed files with 17 additions and 14 deletions
|
@ -12,7 +12,7 @@ def find_metadata(filename):
|
|||
|
||||
metadata = {}
|
||||
|
||||
start_strings = [ ":::spoiler Gitlab sync\n" , ":::spoiler git drive sync\n" ]
|
||||
start_strings = [":::spoiler Gitlab sync\n", ":::spoiler git drive sync\n"]
|
||||
end_str = "\n:::"
|
||||
|
||||
for start_str in start_strings:
|
||||
|
@ -34,5 +34,3 @@ def find_metadata(filename):
|
|||
|
||||
print("Not a valid report")
|
||||
return None
|
||||
|
||||
|
||||
|
|
|
@ -56,7 +56,6 @@ users: {str: [User]} = {}
|
|||
|
||||
|
||||
def loadusers():
|
||||
|
||||
usr = None
|
||||
for name, data in config["mattermost"]["users"].items():
|
||||
if "token" in data:
|
||||
|
|
|
@ -14,7 +14,7 @@ def send_message(file_id, file_info, message):
|
|||
# channel_id = MMApi().get_channel_id("bestuur-dev")
|
||||
channel = ChannelApi(
|
||||
channel_id=channel_id,
|
||||
user=mattermost_client.users[config['mattermost']['selected_user']],
|
||||
user=mattermost_client.users[config["mattermost"]["selected_user"]],
|
||||
)
|
||||
|
||||
prefix = ""
|
||||
|
|
|
@ -71,7 +71,9 @@ def sync_file(drive, repo, path, sync_to):
|
|||
repo.git.push("-u", "origin", branch_name)
|
||||
if not drive.mergerequests.list(source_branch=branch_name, state="opened"):
|
||||
if drive.mergerequests.list(source_branch=branch_name):
|
||||
print(" Creating a new merge request to update the gitlab document with the new version from CodiMD.")
|
||||
print(
|
||||
" Creating a new merge request to update the gitlab document with the new version from CodiMD."
|
||||
)
|
||||
drive.mergerequests.create(
|
||||
{
|
||||
"source_branch": branch_name,
|
||||
|
@ -93,6 +95,7 @@ def sync_file(drive, repo, path, sync_to):
|
|||
else:
|
||||
print(" Note has no changes.")
|
||||
|
||||
|
||||
def init_sync():
|
||||
repo = get_repo()
|
||||
gl = gitlab.Gitlab("https://git.zeus.gent", private_token=TOKEN)
|
||||
|
|
13
src/web.py
13
src/web.py
|
@ -92,6 +92,7 @@ def validate_downloaded_files(post_mattermost_hint=True):
|
|||
|
||||
return db._load_db()
|
||||
|
||||
|
||||
def sync_files_to_gitlab():
|
||||
repo, drive = sync_gitlab.init_sync()
|
||||
for file_id, file_info in db.get_files().items():
|
||||
|
@ -99,9 +100,10 @@ def sync_files_to_gitlab():
|
|||
local_file_path = file_info["local_file_path"]
|
||||
sync_to = file_info["metadata"]["sync-to"]
|
||||
try:
|
||||
sync_gitlab.sync_file(drive, repo, local_file_path, sync_to)
|
||||
sync_gitlab.sync_file(drive, repo, local_file_path, sync_to)
|
||||
except Exception as e:
|
||||
print("Critical error: Failed to sync file to Gitlab")
|
||||
print("Critical error: Failed to sync file to Gitlab")
|
||||
|
||||
|
||||
def sync_files_to_gitea():
|
||||
repo, api_handler = sync.init_sync()
|
||||
|
@ -110,10 +112,11 @@ def sync_files_to_gitea():
|
|||
local_file_path = file_info["local_file_path"]
|
||||
sync_to = file_info["metadata"]["sync-to"]
|
||||
try:
|
||||
sync.sync_file(repo, api_handler, local_file_path, sync_to)
|
||||
sync.sync_file(repo, api_handler, local_file_path, sync_to)
|
||||
except Exception as e:
|
||||
print("Critical error: Failed to sync file to Gitea")
|
||||
traceback.print_exc()
|
||||
print("Critical error: Failed to sync file to Gitea")
|
||||
traceback.print_exc()
|
||||
|
||||
|
||||
@hug.get("/sync-mattermost")
|
||||
def sync_mattermost():
|
||||
|
|
Loading…
Reference in a new issue