def process_params(sys_argv):
    try:
        opts, args = getopt.getopt(sys_argv, 
                                   "".join([opt[0] for opt in OPTS]),
                                    [opt[1] for opt in OPTS]
                                  )
    except getopt.GetoptError as err:
        # print help information and exit:
        print(err) # will print something like "option -a not recognized"
        getopt.usage()
        sys.exit(2)
    #--- Clear params vars ---
    global verbose
    global source_url
    global output_filename

    verbose           = False
    source_url        = ''
    output_filename   = ''


    for o, a in opts:
        if o == "-v":
            verbose = True
        elif o in ("-h", "--help"):
            usage()
            sys.exit()
        elif o in ("-o", "--output"):
            output_filename = a
        elif o in ("-u", "--url"):
            source_url = o
        else:
            assert False, "unhandled option"
Esempio n. 2
0
def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], "cn:cf", ["number_of_contacts", "file"])
    except getopt.GetoptError as err:
            # print help information and exit:
            print(err) # will print something like "option -a not recognized"
            getopt.usage()
            sys.exit(2)

    for o, a in opts:
        if o == "-n":
            n = int(a)
        elif o == "-f":
            f = a
Esempio n. 3
0
from model.group import Group
import random
import string
import os.path
import jsonpickle
import getopt
import sys

try:
    opts, args = getopt.getopt(sys.argv[1:], "n:f:", ["number of groups", 'file'])
except getopt.GetoptError as err:
    getopt.usage()
    sys.exit(2)

n = 5
f = "data/groups.json"

for o, a in opts:
    if o == "-n":
        n = int(a)
    elif o == "-f":
        f = a

constant = [
    Group(name="name1", header="header1", footer="footer1"),
    Group(name="name2", header="header2", footer="footer2")
]

def random_string(prefix, maxlen):
    symbols = string.ascii_letters + string.digits + " "*10
    return prefix + "".join(random.choice(symbols) for i in range(random.randrange(maxlen)))
Esempio n. 4
0
from model.group import Group
import string
import random
import os.path
import jsonpickle
import getopt
import sys

try:
    opts, args = getopt.getopt(sys.argv[1:], "n:f:",
                               ["number of groups", "file"])
except getopt.GetoptError as err:
    getopt.usage()
    sys.exit(2)
n = 2
f = "/data/groups.json"

safechars = string.ascii_letters + string.digits + "~ -_." + "/"

for o, a in opts:
    if o == "-n":
        try:
            n = int(a) - 1
        except ValueError:
            print("-n not a number")
            sys.exit()
    elif o == "-f":
        f = a


def random_string(prefix, maxlength):
Esempio n. 5
0
from model.group import Group
import random
import string
import os.path
import jsonpickle
import getopt
import sys

try:
    opts, args = getopt.getopt(sys.argv[1:], "n:f:",
                               ["number of groups", "file"])
except getopt.GetoptError as err:
    getopt.usage(sys.exit(2))

n = 5
f = "data/groups.json"

for o, a in opts:
    if o == "-n":
        n = int(a)
    elif o == "-f":
        f = a


def random_string(prefix, maxlen):
    symbols = string.ascii_letters + string.digits + string.punctuation + " " * 10
    return prefix + "".join(
        [random.choice(symbols) for i in range(random.randrange(maxlen))])


testdata = [Group(name="", header="", footer="")] + [
Esempio n. 6
0
from model.group import Group
import random
import string
import os.path
import jsonpickle
import getopt
import sys


try:
    opts, args = getopt.getopt(sys.argv[1:], "n:f:", ["number of groups", "file"])
except getopt.GetoptError as err:
    getopt.usage(0)
    sys.exit(2)

n = 5
f = "data/groups.json"

for o, a in opts:
    if o == "-n":
        n = int(a)
    elif o == "-f":
        f = a


def random_string(prefix, maxlen):
    symbols = string.ascii_letters + string.digits + string.punctuation + " "
    return prefix + "".join([random.choice(symbols) for i in range(random.randrange(maxlen))])

Esempio n. 7
0
from model.group import Group
import random
import string
import os.path
import jsonpickle
import getopt
import sys
try:
    opts, args = getopt.getopt(sys.argv[1:], "n:f:",
                               ["number of groups", "file"])
except getopt.GetoptError as err:
    getopt.usage()
    sys.exit(2)
n = 3
f = "data/groups.json"
for o, a in opts:
    if o == "-n":
        n = int(a)
    elif o == "-f":
        f = a

def random_string(prefix, maxlen):
    symbols = string.ascii_letters + string.digits + string.punctuation + " " * 10
    return prefix + "".join(
        [random.choice(symbols) for i in range(random.randrange(maxlen))])

testdata = [Group(name="TestClient")
            ] + [Group(name=random_string("contact", 10)) for i in range(n)]
file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", f)
with open(file, "w") as out: