aboutsummaryrefslogtreecommitdiffstats
path: root/docs/scripts/update_publications.py
blob: 20aa3458738c181288bf05554492674754cb67cd (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import requests, json
from requests.auth import HTTPBasicAuth
import os.path as path
import time

def list_pubs(manual):
    pub_params={}
    user = "to_complete@mageia.org"
    pw = "to_complete"
    site = "http://mageia.calenco.com:8284/workspaces/"
    ws = "Mga7"
    #storsrv = "storageservers/STOR0504658793a605a18f558fcea37f7931"
    storsrv = "storageservers/Default"
    headers = {'content-type': 'application/json'}
    if manual != '':
        pub_params['file'] = manual
    pub_params['input']=  '/workspaces/%s/publications'.format(ws)
    print("Wait to get the list of publications...\n")
    resp = requests.get(site+ws+'/publications', 
            auth=HTTPBasicAuth(user, pw),
            data=json.dumps(pub_params))
    if int(resp.status_code) != 200:
        # This means something went wrong.
        print('GET /workspaces/ {}'.format(resp.status_code))
        exit()
    print("Writing liste.csv")
    with open("listeMga7.csv",'w') as f:
        f.write("Name\thref\tInput\tOutput\tupdated\tStatus\tAutomatic\n")
        for item in resp.json():
            print(item)
            if item['output']['method'] in ('FTP','SFTP'): 
                serv=item['output']['storsrv']
                f.write("{name}\t{href}\t{input}\t{output}\t{updated}\t{status}\t{automatic}\t{server}\t{path}\n".format(name=item["name"],href=item["href"],updated=item["updated"],
                    output=item['output']['name'],status=item["status"],automatic=item["automatic"], input=item['input']['href'], server = serv, path=item['output']['path']))
            else:
                serv=''
    exit() 
      # Set a new storage server
    for item in resp.json():
           # Point to prestored server
            if item['output']['method'] in ('FTP','SFTP'): 
             print('{site}{ws}/publications/{name}'.format(site=site, ws=ws,name=item['name']))
             print(item['output']['path'], item['output']['storsrv'])
             item['output']['rs-path']=item['output']['path']
             if not item['output']['zip'] :
                item['output']['rs-multifile']='multifile'
             item['output']['storsrv']= '/workspaces/{ws}/strorageservers/{storsrv}'.format (ws=ws, storsrv=storsrv)
             resp2 = requests.put('{site}{ws}/publications/{name}'.format(site=site, ws=ws,name=item['name']), 
                    auth=HTTPBasicAuth(user, pw),
                    data=json.dumps(item),
                    headers=headers)
             if int(resp2.status_code) != 200:
                # This means something went wrong.
                print('PUT /workspaces/ {}: {}'.format(resp2.status_code, resp2.text))
             time.sleep(15)
    exit()
    # renew each publication
    for item in resp.json():
        if item['name'].find('WebHelp') != -1:
            pub_params = {}
            pub_params['name']=  item['name']
            print(item['name'], pub_params)
            resp2 = requests.post('{site}{ws}/pubsqueue'.format(site=site, ws=ws), 
                    auth=HTTPBasicAuth(user, pw),
                    data=json.dumps(pub_params),
                    headers=headers)
            if int(resp2.status_code) != 202:
                # This means something went wrong.
                print('GET /workspaces/ {}'.format(resp2.status_code))
                exit()
            # Add delay of 30 seconds between each publication
            time.sleep(30)
        
list_pubs('')
ss="hl kwb">unsigned char *s, unsigned int n) { if (n + SLang_Input_Buffer_Len + 3 > SL_MAX_INPUT_BUFFER_LEN) return -1; SLMEMCPY ((char *) SLang_Input_Buffer + SLang_Input_Buffer_Len, (char *) s, n); SLang_Input_Buffer_Len += n; return 0; } int SLang_ungetkey (unsigned char ch) { return SLang_ungetkey_string(&ch, 1); } int SLang_input_pending (int tsecs) { int n; unsigned char c; if (SLang_Input_Buffer_Len) return (int) SLang_Input_Buffer_Len; n = _SLsys_input_pending (tsecs); if (n <= 0) return 0; c = (unsigned char) SLang_getkey (); SLang_ungetkey_string (&c, 1); return n; } void SLang_flush_input (void) { int quit = SLKeyBoard_Quit; SLang_Input_Buffer_Len = 0; SLKeyBoard_Quit = 0; while (_SLsys_input_pending (0) > 0) { (void) _SLsys_getkey (); /* Set this to 0 because _SLsys_getkey may stuff keyboard buffer if * key sends key sequence (OS/2, DOS, maybe VMS). */ SLang_Input_Buffer_Len = 0; } SLKeyBoard_Quit = quit; } #ifdef IBMPC_SYSTEM static int Map_To_ANSI; int SLgetkey_map_to_ansi (int enable) { Map_To_ANSI = enable; return 0; } static int convert_scancode (unsigned int scan, unsigned int shift, int getkey, unsigned int *ret_key) { unsigned char buf[16]; unsigned char *b; unsigned char end; int is_arrow; shift &= (_SLTT_KEY_ALT|_SLTT_KEY_SHIFT|_SLTT_KEY_CTRL); b = buf; if (_SLTT_KEY_ALT == shift) { shift = 0; *b++ = 27; } *b++ = 27; *b++ = '['; is_arrow = 0; end = '~'; if (shift) { if (shift == _SLTT_KEY_CTRL) end = '^'; else if (shift == _SLTT_KEY_SHIFT) end = '$'; else shift = 0; } /* These mappings correspond to what rxvt produces under Linux */ switch (scan & 0xFF) { default: return -1; case 0x47: /* home */ *b++ = '1'; break; case 0x48: /* up */ end = 'A'; is_arrow = 1; break; case 0x49: /* PgUp */ *b++ = '5'; break; case 0x4B: /* Left */ end = 'D'; is_arrow = 1; break; case 0x4D: /* Right */ end = 'C'; is_arrow = 1; break; case 0x4F: /* End */ *b++ = '4'; break; case 0x50: /* Down */ end = 'B'; is_arrow = 1; break; case 0x51: /* PgDn */ *b++ = '6'; break; case 0x52: /* Insert */ *b++ = '2'; break; case 0x53: /* Delete */ *b++ = '3'; break; case ';': /* F1 */ *b++ = '1'; *b++ = '1'; break; case '<': /* F2 */ *b++ = '1'; *b++ = '2'; break; case '=': /* F3 */ *b++ = '1'; *b++ = '3'; break; case '>': /* F4 */ *b++ = '1'; *b++ = '4'; break; case '?': /* F5 */ *b++ = '1'; *b++ = '5'; break; case '@': /* F6 */ *b++ = '1'; *b++ = '7'; break; case 'A': /* F7 */ *b++ = '1'; *b++ = '8'; break; case 'B': /* F8 */ *b++ = '1'; *b++ = '9'; break; case 'C': /* F9 */ *b++ = '2'; *b++ = '0'; break; case 'D': /* F10 */ *b++ = '2'; *b++ = '1'; break; case 0x57: /* F11 */ *b++ = '2'; *b++ = '3'; break; case 0x58: /* F12 */ *b++ = '2'; *b++ = '4'; break; } if (is_arrow && shift) { if (shift == _SLTT_KEY_CTRL) end &= 0x1F; else end |= 0x20; } *b++ = end; if (getkey) { (void) SLang_buffer_keystring (buf + 1, (unsigned int) (b - (buf + 1))); *ret_key = buf[0]; return 0; } (void) SLang_buffer_keystring (buf, (unsigned int) (b - buf)); return 0; } unsigned int _SLpc_convert_scancode (unsigned int scan, unsigned int shift, int getkey) { unsigned char buf[16]; if (Map_To_ANSI) { if (0 == convert_scancode (scan, shift, getkey, &scan)) return scan; } if (getkey) { buf[0] = scan & 0xFF; SLang_buffer_keystring (buf, 1); return (scan >> 8) & 0xFF; } buf[0] = (scan >> 8) & 0xFF; buf[1] = scan & 0xFF; (void) SLang_buffer_keystring (buf, 2); return 0; } #endif