-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.py
More file actions
73 lines (60 loc) · 2.88 KB
/
check.py
File metadata and controls
73 lines (60 loc) · 2.88 KB
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Programme de vérification des référentiels AMELI
"""
__author__ = 'Frederic Laurent'
__version__ = "1.1"
__copyright__ = 'Copyright 2017, Frederic Laurent'
__license__ = "MIT"
import argparse
import logging
import sys
from easy_atom import helpers
import watchdog
def main():
parser = argparse.ArgumentParser(epilog='''
(*) Lien sur le lien autoréférencé dans ATOM :
https://www.feedvalidator.org/docs/warning/MissingAtomSelfLink.html ''')
parser.add_argument("ref", choices=['ucd', 'lpp', 'ccam', 'nabm'], help="referentiel : ucd | lpp | ccam | nabm")
parser.add_argument("-a", "--action", action="append",
choices=['feed', 'download', 'tweet'],
help="""
action disponible : <feed> -> produit un fichiers de syndication ATOM,
<download> -> télécharge les fichiers
<tweet> -> poste 1 tweet concernant la mise a jour""")
parser.add_argument("--feedbase",
help="URL de base des flux atom, utilisés dans le flux ATOM pour s'autoréférencer (*)")
parser.add_argument("--feedftp", help="configuration FTP pour upload du flux ATOM, format JSON")
parser.add_argument("--dataftp", help="configuration FTP pour upload des données, format JSON")
parser.add_argument("--twitter", help="configuration Twitter permettant de poster la mise à jour")
parser.add_argument("--mail", help="configuration Mail pour envoyer une notification, format JSON")
parser.add_argument("--backupdir", help="Répertoire de sauvegarde des pages html")
parser.add_argument("--downdir", help="Répertoire de téléchargements des fichiers de données")
args = parser.parse_args()
if not args.action:
sys.stderr.write("## Erreur >> Aucune action définie !\n\n")
parser.print_help(sys.stderr)
sys.exit(1)
feed_conf = {
'ftp_config': args.feedftp,
'feed_base': args.feedbase
}
data_conf = {
'download': 'download' in args.action,
'ftp_config': args.dataftp,
'backup_dir': args.backupdir if args.backupdir else 'backup',
'download_dir': args.downdir if args.downdir else 'down' }
wd_class = {"ucd": watchdog.UCDWatchDog,
"lpp": watchdog.LPPWatchDog,
"ccam": watchdog.CCAMWatchDog,
"nabm": watchdog.NABMWatchDog}
instance = wd_class[args.ref](nomen=args.ref,
feed_conf=feed_conf,
data_conf=data_conf,
mail_conf=args.mail,
tweet_conf=args.twitter)
instance.process()
if __name__ == "__main__":
loggers = helpers.stdout_logger(['ccam_wd', 'lpp_wd', 'ucd_wd', 'nabm_wd', 'feed', 'action'], logging.DEBUG)
main()