예제 #1
0
파일: webapp.py 프로젝트: supergis/pyrocore
def redirect(req, _log=pymagic.get_lazy_logger("redirect")):
    """ Redirect controller to emit a HTTP 301.
    """
    log = req.environ.get("wsgilog.logger", _log)
    target = req.relative_url(req.urlvars.to)
    log.info("Redirecting '%s' to '%s'" % (req.url, target))
    return exc.HTTPMovedPermanently(location=target)
예제 #2
0
def redirect(req, _log=pymagic.get_lazy_logger("redirect")):
    """ Redirect controller to emit a HTTP 301.
    """
    log = req.environ.get("wsgilog.logger", _log)
    target = req.relative_url(req.urlvars.to)
    log.info("Redirecting '%s' to '%s'" % (req.url, target))
    return exc.HTTPMovedPermanently(location=target)
예제 #3
0
파일: matching.py 프로젝트: zapras/pyrocore
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import re
import time
import shlex
import fnmatch
import operator

from pyrocore import error, config
from pyrocore.util import fmt, pymagic

log = pymagic.get_lazy_logger(__name__)

TRUE = set((
    "true",
    "t",
    "yes",
    "y",
    "1",
    "+",
))
FALSE = set((
    "false",
    "f",
    "no",
    "n",
    "0",
예제 #4
0
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

import re
import sys
import json
import operator

from pyrobase import templating
from pyrobase.parts import Bunch

from pyrocore import error, config
from pyrocore.torrent import engine
from pyrocore.util import os, fmt, algo, pymagic


log = pymagic.get_lazy_logger(__name__)


#
# Format specifiers
#
def fmt_sz(intval):
    """ Format a byte sized value.
    """
    try:
        return fmt.human_size(intval)
    except (ValueError, TypeError):
        return "N/A".rjust(len(fmt.human_size(0)))


def fmt_iso(timestamp):