olinox 4 years ago
parent
commit
6a03a9b794
7 changed files with 6 additions and 186 deletions
  1. 3 1
      README.md
  2. 1 1
      VERSION
  3. 0 47
      core/logging.yaml
  4. 0 64
      core/logging_.py
  5. 0 65
      deployer_app.TXT
  6. 1 4
      main.py
  7. 1 4
      requirements.txt

+ 3 - 1
README.md

@@ -1,4 +1,6 @@
-# Hello World
+# ALEXANDRIE
+
+A simple library / classifier for your media files
 
 A model for a basic python app 
 

+ 1 - 1
VERSION

@@ -1 +1 @@
-1.0
+0.1

+ 0 - 47
core/logging.yaml

@@ -1,47 +0,0 @@
-version: 1
-disable_existing_loggers: no
-formatters:
-    simple:
-        format: "%(asctime)s - %(levelname)s - %(message)s"
-    complete:
-        format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
-    short:
-        format: "%(levelname)s - %(message)s"
-    message_only:
-        format: "%(message)s"
-        
-handlers:
-    console:
-        class: logging.StreamHandler
-        level: INFO
-        formatter: message_only
-        stream: ext://sys.stdout
-    file:
-        class: logging.handlers.RotatingFileHandler
-        level: DEBUG
-        formatter: complete
-        filename: debug.log
-        maxBytes: 100000
-        backupCount: 1
-        encoding: utf8
-    mail:
-        class: core.logging_.BufferingSMTPHandler
-        level: ERROR
-        formatter: complete
-        mailhost: smtp.bas-rhin.fr
-        fromaddr: log.hello@bas-rhin.fr
- #       toaddrs: [user.name@bas-rhin.fr]
-        toaddrs: []
-        subject: log
-        capacity: 100000000
-        
-loggers:
-    hello:
-        level: DEBUG
-        handlers: [console, file, mail]
-        propagate: no
-       
-root:
-    level: INFO
-    handlers: [console]
-    propagate: yes

+ 0 - 64
core/logging_.py

@@ -1,64 +0,0 @@
-'''
-Created on 6 juil. 2017
-
-@author: olivier.massot
-'''
-from datetime import datetime
-from email.mime.text import MIMEText
-import logging.config
-import smtplib
-import sys
-
-from path import Path
-import yaml
-
-LOG_DIR = Path(r"%appdata%\logs").expandvars()
-LOG_DIR.makedirs_p()
-
-SYS_EXCEPT_HOOK = sys.excepthook
-
-def start(name="main", level=0, filename=""):
-    # charge la configuration du logging depuis le fichier 'logging.yaml'
-    configfile = Path(__file__).parent
-    with open(configfile / 'logging.yaml', 'rt') as f:
-        conf = yaml.load(f)
-
-    if level:
-        conf["loggers"][name]["level"] = level
-
-    if not filename:
-        filename = LOG_DIR / r'{}_{:%Y%m%d_%H%M}.log'.format(name, datetime.now())
-    conf["handlers"]["file"]["filename"] = filename
-
-    logging.config.dictConfig(conf)
-
-    logger = logging.getLogger(name)
-    logger.info("Log start written at {}".format(filename))
-
-class BufferingSMTPHandler(logging.handlers.BufferingHandler):
-    def __init__(self, mailhost, fromaddr, toaddrs, subject, capacity):
-        logging.handlers.BufferingHandler.__init__(self, capacity)
-        self.mailhost = mailhost
-        self.mailport = None
-        self.fromaddr = fromaddr
-        self.toaddrs = toaddrs
-        self.subject = subject
-
-    def flush(self):
-        try:
-            if len(self.buffer) > 0:
-                port = self.mailport if self.mailport else smtplib.SMTP_PORT
-
-                msg = "\n".join([self.format(record) for record in self.buffer])
-                msg = MIMEText(msg.encode('utf-8'), _charset='utf-8')
-                msg['Subject'] = self.subject
-                msg['From'] = self.fromaddr
-                msg['To'] = ",".join(self.toaddrs)
-
-                smtp = smtplib.SMTP(self.mailhost, port)
-                smtp.sendmail(self.fromaddr, self.toaddrs, msg.as_string())
-                smtp.quit()
-                self.buffer = []
-        except Exception as e:
-            print(e)
-            raise

+ 0 - 65
deployer_app.TXT

@@ -1,65 +0,0 @@
-Pour deployer une application python:
-http://sametmax.com/creer-un-setup-py-et-mettre-sa-bibliotheque-python-en-ligne-sur-pypi/
-
-1- Créer sa lib (ici: "lib_exemple")
-2- la mettre dans un dossier portant le même nom:
-
-- lib_exemple
-   - MANIFEST.in [un fichier texte qui liste les fichiers non Python qu’on inclura dans l’installation]
-   - README.md  [un fichier markdown contiendra une présentation du package]
-   - setup.py
-   - lib_exemple
-      - main.py
-      - core
-      - ui
-      ...Etc
-
-3- pour l'installeur, on devrait utiliser distutils ou setuptools (plus complet, gère les dépendances)
-
-4- rendre notre paquet plus facile à utiliser 
-- en documentant: on décrit le package dans __init__, le module dans l'en-tête du fichier, puis chaque fonction
-- en faisant les differents imports depuis le __init__ principal, de manière à ce que l'utilisateur puisse faire
-import lib_exemple.calcul plutôt que lib_exemple.core.calcul
-- en creant une variable __all__ = ['calcul'] pour limiter les fonctions importables avec *
-- en ajoutant une version: 
-__version__ = "0.0.1"
-
-5 - dans le readme:
-    - A quoi sert la lib.
-    - Comment l’installer.
-    - Un exempe concret d’utilisation.
-    - La licence d’utilisation.
-    - Un lien vers la doc si elle existe
-au format markdown:
-https://daringfireball.net/projects/markdown/basics
-
-6 - dans le manifest, ajouter des include et recursive-include pour ajouter les fichiers non python
-
-7- creer le setup.py (cf PJ)
-
-8- dans le dossier principal, executer:
-python setup.py install
-
-9- si la lib s'est bien installée, on doit pouvoir faire avec la console python:
-> from lib_exemple import fonction_test
-> fonction_test()
-
-et avec l'invite de commande si on a créé des commandes dans le setup
-
-
-10- pour enregistrer sur Pypi (et rendre la lib installable avec pip):
-python setup.py register
-- choisir option 2 la première fois et créer son compte, puis choisir 1 ensuite
-
-le but est d'obtenir ceci:
-Registering lib_exemple to http://pypi.python.org/pypi
-Server response (200): OK
-
-puis executer:
-python setup.py sdist upload
-
-11- par la suite, pour uploader à nouveau, le numero de version doit être modifié
-
-
-
-

+ 1 - 4
main.py

@@ -11,8 +11,8 @@ import traceback
 
 from PyQt5.Qt import QApplication
 from PyQt5.QtWidgets import QMessageBox
+from log0 import logger
 
-from core import logging_
 from ui.window import MainWindow
 from updater import UpdateNeeded
 import updater
@@ -25,9 +25,6 @@ try:
 except:
     pass
 
-logger = logging.getLogger("hello")
-logging_.start("hello", level=10)
-
 with open("VERSION") as f:
     __VERSION__ = f.read()
 

+ 1 - 4
requirements.txt

@@ -1,6 +1,3 @@
-# PyQt5: only if it app needs a graphical interface
 PyQt5
-
-# requests is used by the auto-updater
 requests
-
+log0