<commit_before>#!/usr/bin/env python

"""Command-line interface for SLAM."""

import os, pwd, sys, argparse, logging, signal

os.environ["DJANGO_SETTINGS_MODULE"] = "webinterface.settings"

from slam import models, interface, addrrange, generator

def init_argparser():
    """Initialize the SLAM argparser."""
    argparser = argparse.ArgumentParser(
        description= "SLAM command-line interface")
    argparser.add_argument("-a", "--action", action="append", required=True,
        choices=["list", "create", "get", "delete", "modify", "setprop",
            "rmprop", "createconf", "upconf", "log", "export"],
        help="The action to perform: list | create | get | delete | modify "
            + "| setprop | rmprop | createconf | upconf | export")
    argparser.add_argument("-pn", "--pool-name", action="append",
        help="The name of an address pool.")
    argparser.add_argument("-c", "--category", action="append",
        help="The category of an address pool.")
    argparser.add_argument("-p", "--pool",
        help="Address definition of the pool to manage "
            + "(ex: 10.1.2.0/24, fc00::/7, \"addr1,addr2,addr3\").")
    argparser.add_argument("-A", "--address", action="append",
        help= "An address to list, allocate or free.")
    argparser.add_argument("-m", "--mac", action="append",
        help= "A mac-address to bind to a host.")
    argparser.add_argument("-H", "--host", action="append",
        help="The name of the host to manage.")<commit_msg>slam_cli: work around a problem loading settings in Django 1.8<commit_after>#!/usr/bin/env python

"""Command-line interface for SLAM."""

import os
import sys
import pwd
import argparse
import logging
import signal

# FIXME - MJ 21/9/2017
# For some reasons, in Django 1.5, settings is not found if in a submodule, like
# webinterface.settings. This hacks work around the problem.
sys.path.insert(0, '{}/webinterface'.format(os.path.dirname(os.path.abspath(__file__))))
os.environ["DJANGO_SETTINGS_MODULE"] = "settings"

from slam import models, interface, addrrange, generator

def init_argparser():
    """Initialize the SLAM argparser."""
    argparser = argparse.ArgumentParser(
        description= "SLAM command-line interface")
    argparser.add_argument("-a", "--action", action="append", required=True,
        choices=["list", "create", "get", "delete", "modify", "setprop",
            "rmprop", "createconf", "upconf", "log", "export"],
        help="The action to perform: list | create | get | delete | modify "
            + "| setprop | rmprop | createconf | upconf | export")
    argparser.add_argument("-pn", "--pool-name", action="append",
        help="The name of an address pool.")
    argparser.add_argument("-c", "--category", action="append",
        help="The category of an address pool.")
    argparser.add_argument("-p", "--pool",
        help="Address definition of the pool to manage "
            + "(ex: 10.1.2.0/24, fc00::/7, \"addr1,addr2,addr3\").")
    argparser.add_argument("-A", "--address", action="append",
        help= "An address to list, allocate or free.")
    argparser.add_argument("-m", "--mac", action="append",
        help= "A mac-address to bind to a host.")
    argparser.add_argument("-H", "--host", action="append",
        help="The name of the host to manage.")
{'fraction_non_alphanumeric': 0.16616496086694763, 'fraction_numerical': 0.011438892233594221, 'mean_word_length': 3.4604026845637583, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7100974', 'n_tokens_mistral': 1003, 'n_tokens_neox': 1002, 'n_words': 292}