Commit 1c9720d7 authored by Dimitri Podborski's avatar Dimitri Podborski
Browse files

change descrition / ignore entries with the wrong number of entrie

parent 8a6593aa
#! /usr/local/bin/python3
# coding: utf-8
"""
Script for managing the GitLab issues for MPEG
To work properly this script requires following:
1. GITLAB_TOKEN environment variable to be set to your private token.
Create your token here: http://mpegx.int-evry.fr/software/profile/personal_access_tokens
2. GitLabI API module: pip install --upgrade python-gitlab
3. CSV module: pip install csv
4. curl installed on your system
5. Set the following environment variables: MPEG_LOGIN, MPEG_PWD
This is just a hack to test the MDMS and GitLab API
"""
__author__ = "Dimitri Podborski"
__version__ = "0.0.1"
import os
import sys
import argparse
......@@ -27,8 +16,9 @@ TOKEN = os.environ.get('GITLAB_TOKEN')
BASEURL = "https://dms.mpeg.expert/"
FIND_CONTRIBUTION_URL = "https://dms.mpeg.expert/doc_end_user/searchAcross.php"
GET_CONTRIBUTION_URL = "https://dms.mpeg.expert/doc_end_user/current_document.php"
# TODO: let the user input it, or search it
PROJECT_ID = 272 # this ID is my private repo for testing. You can figure out your ID by running list_all_projects
PROJECT_ID = 316 # this ID is my private repo for testing. You can figure out your ID by running list_all_projects
# TODO: this (and other metadata) should be passed from the CSV file as input
contributions = ['55686', '56083']
......@@ -103,7 +93,7 @@ gl = gitlab.Gitlab('http://mpegx.int-evry.fr/software', private_token=TOKEN)
# get entries for each contribution
entries = []
for contrNr in contributions:
searchCmd = "curl -s -X POST -d 'search_title=&search_number=" + contrNr + "&search_category=&search_author=&search_id_group=1&search_sub_group=1&id_meeting=&submit=Search&meeting=' -u $MPEG_LOGIN:$MPEG_PWD https://dms.mpeg.expert/doc_end_user/searchAcross.php"
searchCmd = "curl -s -X POST -d 'search_title=&search_number=" + contrNr + "&search_category=&search_author=&search_id_group=1&search_sub_group=1&id_meeting=&submit=Search&meeting=' -u $MPEG_LOGIN:$MPEG_PWD " + FIND_CONTRIBUTION_URL
alltext = command_to_string(searchCmd)
......@@ -113,12 +103,12 @@ for contrNr in contributions:
pos2 = alltext.find('&', pos1+len(pattern)+1)
docID = alltext[pos1+len(pattern):pos2]
getCmd = "curl -s -X POST -d 'id=" + docID + "&id_meeting=' -u $MPEG_LOGIN:$MPEG_PWD https://dms.mpeg.expert/doc_end_user/current_document.php"
getCmd = "curl -s -X POST -d 'id=" + docID + "&id_meeting=' -u $MPEG_LOGIN:$MPEG_PWD " + GET_CONTRIBUTION_URL
alltext = command_to_string(getCmd)
entry = get_table_entry(alltext, contrNr)
# TODO: rewrite this dirty hack
# NOTE: we should not do it like this
findPattern = 'href="../'
startUrl = alltext.rfind(findPattern)
endUrl = alltext.find('">', startUrl + len(findPattern))
......@@ -139,6 +129,9 @@ print("\n\n\n")
# TODO: move it to its own method
n = 0
for line in entries:
if len(line) < 14:
print("Parsing failed")
continue
title = line[12] + ' ' + line[0]
authors = line[1]
org = line[2]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment