Skip to content

Commit

Permalink
dynamic AUTOLOAD.DWL works!
Browse files Browse the repository at this point in the history
  • Loading branch information
jedie committed Nov 20, 2014
1 parent 711916d commit 090a408
Show file tree
Hide file tree
Showing 12 changed files with 319 additions and 509 deletions.
Binary file removed dwload-demo-files/AUTOLOAD.DWL
Binary file not shown.
60 changes: 3 additions & 57 deletions dwload-demo-files/AUTOLOAD.DWL.py
Expand Up @@ -2,62 +2,8 @@
# encoding:utf-8

"""
DwLoadServer - A DWLOAD server written in Python
================================================
:created: 2014 by Jens Diemer - www.jensdiemer.de
:copyleft: 2014 by the DwLoadServer team, see AUTHORS for more details.
:license: GNU GPL v3 or above, see LICENSE for more details.
copy this file into your DWLOAD server root directory!
"""

import argparse
import os
import logging
import sys

try:
import dragonlib
except ImportError as err:
raise ImportError("dragonlib from https://github.com/jedie/DragonPy is needed: %s" % err)

from dragonlib.utils.logging_utils import setup_logging, LOG_LEVELS


log = logging.getLogger(__name__)


def get_content():
"""
Only a DEMO, doesn't do really fancy stuff.
Just read the existing AUTOLOAD.DWL and return the bytes...
"""
log.info("Create AUTOLOAD.DWL 'on-the-fly'...")

filepath = os.path.abspath(os.path.join(
os.path.dirname(__file__), "AUTOLOAD.DWL"
))
log.debug("Open %r...", filepath)
with open(filepath, "rb") as f:
content = f.read()

log.debug("%i bytes readed.", len(content))

return content


def cli():
parser = argparse.ArgumentParser()
parser.add_argument(
'--log_level', dest="log_level", type=int, choices=LOG_LEVELS, default=logging.INFO,
help="Logging level: 10=DEBUG, 20=INFO, 30=WARNING, 40=ERROR, 50=CRITICAL/FATAL"
)
args = parser.parse_args()

setup_logging(level=args.log_level)

content = get_content()
sys.stdout.buffer.write(content)


if __name__ == '__main__':
cli()
from dwload_server.pyscripts.autoload_dwl import cli
cli()
2 changes: 1 addition & 1 deletion dwload_server/__init__.py
@@ -1 +1 @@
__version__="0.3.0"
__version__="0.4.0.dev"

0 comments on commit 090a408

Please sign in to comment.