mirror of
https://github.com/lilydjwg/archrepo2.git
synced 2025-03-10 12:02:43 +00:00
remove winterpy dependency
This commit is contained in:
parent
47e7cbce53
commit
da2e89df66
9 changed files with 115 additions and 7 deletions
|
@ -15,7 +15,6 @@ DEPENDENCIES
|
||||||
- distribute
|
- distribute
|
||||||
- tornado, > 2.4.1
|
- tornado, > 2.4.1
|
||||||
- pyinotify, tested with 0.9.4
|
- pyinotify, tested with 0.9.4
|
||||||
- winterpy (add ``pylib`` to ``$PYTHONPATH``)
|
|
||||||
|
|
||||||
NOTE
|
NOTE
|
||||||
====
|
====
|
||||||
|
@ -28,7 +27,6 @@ TODO
|
||||||
|
|
||||||
- [high] adding and then removing it before adding complete will result
|
- [high] adding and then removing it before adding complete will result
|
||||||
in not-in-database removing
|
in not-in-database removing
|
||||||
- [high] remove winterpy dependency
|
|
||||||
- [middle] disable "any" architecture via config
|
- [middle] disable "any" architecture via config
|
||||||
- [low] fork to background
|
- [low] fork to background
|
||||||
- [low] use one common command queue (now one each repo)
|
- [low] use one common command queue (now one each repo)
|
||||||
|
|
|
@ -6,7 +6,7 @@ import logging
|
||||||
|
|
||||||
from tornado.ioloop import IOLoop
|
from tornado.ioloop import IOLoop
|
||||||
|
|
||||||
from myutils import enable_pretty_logging
|
from .lib.nicelogger import enable_pretty_logging
|
||||||
enable_pretty_logging(logging.DEBUG)
|
enable_pretty_logging(logging.DEBUG)
|
||||||
|
|
||||||
from .repomon import repomon
|
from .repomon import repomon
|
||||||
|
|
5
archrepo2/lib/__init__.py
Normal file
5
archrepo2/lib/__init__.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
'''
|
||||||
|
moduels in this directory are taken from `winterpy <https://github.com/lilydjwg/winterpy>`_.
|
||||||
|
|
||||||
|
last sync is at 2013-08-23.
|
||||||
|
'''
|
36
archrepo2/lib/archpkg.py
Normal file
36
archrepo2/lib/archpkg.py
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
import os
|
||||||
|
from collections import defaultdict, namedtuple
|
||||||
|
|
||||||
|
from pkg_resources import parse_version
|
||||||
|
|
||||||
|
class PkgNameInfo(namedtuple('PkgNameInfo', 'name, version, release, arch')):
|
||||||
|
def __lt__(self, other):
|
||||||
|
if self.name != other.name or self.arch != other.arch:
|
||||||
|
return NotImplemented
|
||||||
|
if self.version != other.version:
|
||||||
|
return parse_version(self.version) < parse_version(other.version)
|
||||||
|
return int(self.release) < int(other.release)
|
||||||
|
|
||||||
|
def __gt__(self, other):
|
||||||
|
# No, try the other side please.
|
||||||
|
return NotImplemented
|
||||||
|
|
||||||
|
@property
|
||||||
|
def fullversion(self):
|
||||||
|
return '%s-%s' % (self.version, self.release)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def parseFilename(cls, filename):
|
||||||
|
return cls(*trimext(filename, 3).rsplit('-', 3))
|
||||||
|
|
||||||
|
def trimext(name, num=1):
|
||||||
|
for i in range(num):
|
||||||
|
name = os.path.splitext(name)[0]
|
||||||
|
return name
|
||||||
|
|
||||||
|
def finddups(pkgs, n=1):
|
||||||
|
ret = defaultdict(list)
|
||||||
|
for f in pkgs:
|
||||||
|
name, ver, build, arch = PkgNameInfo.parseFilename(os.path.split(f)[1])
|
||||||
|
ret[name].append('%s-%s' % (ver, build))
|
||||||
|
return {k: sorted(v) for k, v in ret.items() if len(v) > n}
|
69
archrepo2/lib/nicelogger.py
Normal file
69
archrepo2/lib/nicelogger.py
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import logging
|
||||||
|
|
||||||
|
class TornadoLogFormatter(logging.Formatter):
|
||||||
|
def __init__(self, color, *args, **kwargs):
|
||||||
|
super().__init__(self, *args, **kwargs)
|
||||||
|
self._color = color
|
||||||
|
if color:
|
||||||
|
import curses
|
||||||
|
curses.setupterm()
|
||||||
|
if sys.hexversion < 50463728:
|
||||||
|
fg_color = str(curses.tigetstr("setaf") or
|
||||||
|
curses.tigetstr("setf") or "", "ascii")
|
||||||
|
else:
|
||||||
|
fg_color = curses.tigetstr("setaf") or curses.tigetstr("setf") or b""
|
||||||
|
self._colors = {
|
||||||
|
logging.DEBUG: str(curses.tparm(fg_color, 4), # Blue
|
||||||
|
"ascii"),
|
||||||
|
logging.INFO: str(curses.tparm(fg_color, 2), # Green
|
||||||
|
"ascii"),
|
||||||
|
logging.WARNING: str(curses.tparm(fg_color, 3), # Yellow
|
||||||
|
"ascii"),
|
||||||
|
logging.ERROR: str(curses.tparm(fg_color, 1), # Red
|
||||||
|
"ascii"),
|
||||||
|
}
|
||||||
|
self._normal = str(curses.tigetstr("sgr0"), "ascii")
|
||||||
|
|
||||||
|
def format(self, record):
|
||||||
|
try:
|
||||||
|
record.message = record.getMessage()
|
||||||
|
except Exception as e:
|
||||||
|
record.message = "Bad message (%r): %r" % (e, record.__dict__)
|
||||||
|
record.asctime = time.strftime(
|
||||||
|
"%m-%d %H:%M:%S", self.converter(record.created))
|
||||||
|
record.asctime += '.%03d' % ((record.created % 1) * 1000)
|
||||||
|
prefix = '[%(levelname)1.1s %(asctime)s %(module)s:%(lineno)d]' % \
|
||||||
|
record.__dict__
|
||||||
|
if self._color:
|
||||||
|
prefix = (self._colors.get(record.levelno, self._normal) +
|
||||||
|
prefix + self._normal)
|
||||||
|
formatted = prefix + " " + record.message
|
||||||
|
if record.exc_info:
|
||||||
|
if not record.exc_text:
|
||||||
|
record.exc_text = self.formatException(record.exc_info)
|
||||||
|
if record.exc_text:
|
||||||
|
formatted = formatted.rstrip() + "\n" + record.exc_text
|
||||||
|
return formatted.replace("\n", "\n ")
|
||||||
|
|
||||||
|
def enable_pretty_logging(level=logging.DEBUG):
|
||||||
|
logger = logging.getLogger()
|
||||||
|
h = logging.StreamHandler()
|
||||||
|
formatter = logging.Formatter('%(asctime)s:%(levelname)-7s:%(name)-12s:%(message)s')
|
||||||
|
try:
|
||||||
|
import curses
|
||||||
|
color = False
|
||||||
|
curses.setupterm()
|
||||||
|
if curses.tigetnum("colors") > 0:
|
||||||
|
color = True
|
||||||
|
formatter = TornadoLogFormatter(color=color)
|
||||||
|
except:
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
|
finally:
|
||||||
|
h.setLevel(level)
|
||||||
|
h.setFormatter(formatter)
|
||||||
|
logger.setLevel(level)
|
||||||
|
logger.addHandler(h)
|
||||||
|
|
|
@ -19,7 +19,7 @@ Event = pyinotify.Event
|
||||||
from tornado.ioloop import IOLoop
|
from tornado.ioloop import IOLoop
|
||||||
import tornado.process
|
import tornado.process
|
||||||
|
|
||||||
import archpkg
|
from .lib import archpkg
|
||||||
from . import pkgreader
|
from . import pkgreader
|
||||||
from . import dbutil
|
from . import dbutil
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import configparser
|
||||||
import pickle
|
import pickle
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from myutils import enable_pretty_logging
|
from archrepo2.lib.nicelogger import enable_pretty_logging
|
||||||
enable_pretty_logging(logging.DEBUG)
|
enable_pretty_logging(logging.DEBUG)
|
||||||
|
|
||||||
import archrepo2.pkgreader
|
import archrepo2.pkgreader
|
||||||
|
|
|
@ -6,7 +6,7 @@ import sqlite3
|
||||||
import pickle
|
import pickle
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from myutils import enable_pretty_logging
|
from archrepo2.lib.nicelogger import enable_pretty_logging
|
||||||
enable_pretty_logging(logging.DEBUG)
|
enable_pretty_logging(logging.DEBUG)
|
||||||
|
|
||||||
from archrepo2.dbutil import *
|
from archrepo2.dbutil import *
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -7,7 +7,7 @@ setup(
|
||||||
name = 'archrepo2',
|
name = 'archrepo2',
|
||||||
version = archrepo2.__version__,
|
version = archrepo2.__version__,
|
||||||
packages = find_packages(),
|
packages = find_packages(),
|
||||||
install_requires = ['tornado>2.4.1', 'pyinotify'],
|
install_requires = ['tornado>2.4.1', 'pyinotify', 'distribute'],
|
||||||
entry_points = {
|
entry_points = {
|
||||||
'console_scripts': [
|
'console_scripts': [
|
||||||
'archreposrv = archrepo2.archreposrv:main',
|
'archreposrv = archrepo2.archreposrv:main',
|
||||||
|
|
Loading…
Add table
Reference in a new issue