<commit_before>#!/usr/bin/env python
## Author:      <NAME>
## Date:        2007-06-04
## Description: Use the Exscript interpreter with a multi threaded configuration
##              engine to execute commands on a list of hosts.
import sys, time, os, re, signal, gc, copy, socket, getpass
sys.path.insert(0, 'lib')
import Exscript
from FooLib          import Interact
from FooLib          import OptionParser
from FooLib          import UrlParser
from WorkQueue       import WorkQueue
from WorkQueue       import Sequence
from TerminalActions import *

True  = 1
False = 0

__version__ = '0.9.11'

def usage():
    print "Exscript %s" % __version__
    print "Copyright (C) 2007 by <NAME> <http://debain.org>."
    print "Syntax: ./exscript.py [options] exscript [hostname [hostname ...]]"
    print "  -a, --authorize"
    print "                 When given, authorization is performed on devices that"
    print "                 support AAA (by default, Exscript only authenticates)"
    print "  -A, --authorize2"
    print "                 Like -a, but uses the authentication password instead of"
    print "                 asking for a password to be entered."
    print "  -c, --connections=NUM"
    print "                 Maximum number of concurrent connections."
    print "                 NUM is a number between 1 and 20, default is 1"
    print "      --csv-hosts FILE"
    print "                 Loads a list of hostnames and definitions from the given file."
    print "                 The first line of the file must have the column headers in the"
    print "                 following syntax:"
    print "                    hostname [variable] [variable] ..."
    print "                 where the fields are separated by tabs, \"hostname\" is the"
    print "                 keyword \"hostname\" and \"variable\" is a unique name under"
    print "                 which the column is accessed in the script."
    print "                 The following lines contain the hostname in the first column,"
    print "                 and the values of the variables in the following columns."
    print "  -d, --define PAIR"
    print "                 Defines a variable that is passed to the script."
    print "                 PAIR has the following syntax: <STRING>=<STRING>."
    print "      --hosts FILE"
    print "                 Loads a list of hostnames from the given file (one host per"
    print "                 line)."
    print "  -l, --logdir DIR"
    print "                 Logs any communication into the directory with the given name."
    print "                 Each filename consists of the hostname with \"_log\" appended."
    print "                 Errors are written to a separate file, where the filename"
    print "                 consists of the hostname with \".log.error\" appended."
    print "      --no-echo"
    print "                 Turns off the echo, such that the network activity is no longer"
    print "                 written to stdout."
    print "                 This is already the default behavior if the -c option was given"
    print "                 with a number greater than 1."
    print "  -n, --no-authentication"
    print "                 When given, the authentication procedure is skipped."
    print "  -p, --protocol STRING"
    print "                 Specify which protocol to use to connect to the remote host."
    print "                 STRING is one of: telnet ssh"
    print "                 The default protocol is telnet."
    print "  -v, --verbose NUM"
    print "                 Print out debug information about the network activity."
    print "                 NUM is a number between 0 (min) and 5 (max)"
    print "  -V, --parser-verbose NUM"
    print "                 Print out debug information about the Exscript parser."
    print "                 NUM is a number between 0 (min) and 5 (max)"
    print "      --version  Prints the version number."
    print "  -h, --help     Prints this help."

# Define default options.
default_options = [
  ('authorize',         'a',  False),
  ('authorize2',        'A',  False),
  ('no-echo',           None, False),
  ('connections=',      'c:', 1),
  ('csv-hosts=',        None, None),
  ('define=',           'd:', {'hostname': 'unknown'}),
  ('hosts=',            None, None),
  ('logdir=',           'l:', None),
  ('protocol=',         'p:', 'telnet'),
  ('no-authentication', 'n',  False),
  ('verbose=',          'v:', 0),
  ('parser-verbose=',   'V:', 0),
  ('version',           None, False),
  ('help',              'h',  False)
]

# Parse options.
try:
    options, args = OptionParser.parse_options(sys.argv, default_options)
except:
    usage()
    sys.exit(1)

# Show the help, if requested.
if options['help']:
    usage()
    sys.exit()

# Show the version number, if requested.
if options['version']:
    print "Exscript %s" % __version__
    sys.exit()

# Check command line syntax.
if options['authorize'] and options['authorize2']:
    print "Error: Can't use both, -a and -A switch."
    sys.exit(1)
if options['no-authenticate'] and options['authorize']:
    print "Error: Can't use both, -n and -a switch."
    sys.exit(1)
if options['no-authenticate'] and options['authorize2']:
    print "Error: Can't use both, -n and -A switch."
    sys.exit(1)

try:
    exscript  = args.pop(0)
    hostnames = args
except:
    usage()
    sys.exit(1)
defines = dict([(hostname, options['define']) for hostname in hostnames])
<commit_msg>* Fix: Last commit was broken. -Samuel<commit_after>#!/usr/bin/env python
## Author:      <NAME>
## Date:        2007-06-04
## Description: Use the Exscript interpreter with a multi threaded configuration
##              engine to execute commands on a list of hosts.
import sys, time, os, re, signal, gc, copy, socket, getpass
sys.path.insert(0, 'lib')
import Exscript
from FooLib          import Interact
from FooLib          import OptionParser
from FooLib          import UrlParser
from WorkQueue       import WorkQueue
from WorkQueue       import Sequence
from TerminalActions import *

True  = 1
False = 0

__version__ = '0.9.11'

def usage():
    print "Exscript %s" % __version__
    print "Copyright (C) 2007 by <NAME> <http://debain.org>."
    print "Syntax: ./exscript.py [options] exscript [hostname [hostname ...]]"
    print "  -a, --authorize"
    print "                 When given, authorization is performed on devices that"
    print "                 support AAA (by default, Exscript only authenticates)"
    print "  -A, --authorize2"
    print "                 Like -a, but uses the authentication password instead of"
    print "                 asking for a password to be entered."
    print "  -c, --connections=NUM"
    print "                 Maximum number of concurrent connections."
    print "                 NUM is a number between 1 and 20, default is 1"
    print "      --csv-hosts FILE"
    print "                 Loads a list of hostnames and definitions from the given file."
    print "                 The first line of the file must have the column headers in the"
    print "                 following syntax:"
    print "                    hostname [variable] [variable] ..."
    print "                 where the fields are separated by tabs, \"hostname\" is the"
    print "                 keyword \"hostname\" and \"variable\" is a unique name under"
    print "                 which the column is accessed in the script."
    print "                 The following lines contain the hostname in the first column,"
    print "                 and the values of the variables in the following columns."
    print "  -d, --define PAIR"
    print "                 Defines a variable that is passed to the script."
    print "                 PAIR has the following syntax: <STRING>=<STRING>."
    print "      --hosts FILE"
    print "                 Loads a list of hostnames from the given file (one host per"
    print "                 line)."
    print "  -l, --logdir DIR"
    print "                 Logs any communication into the directory with the given name."
    print "                 Each filename consists of the hostname with \"_log\" appended."
    print "                 Errors are written to a separate file, where the filename"
    print "                 consists of the hostname with \".log.error\" appended."
    print "      --no-echo"
    print "                 Turns off the echo, such that the network activity is no longer"
    print "                 written to stdout."
    print "                 This is already the default behavior if the -c option was given"
    print "                 with a number greater than 1."
    print "  -n, --no-authentication"
    print "                 When given, the authentication procedure is skipped."
    print "  -p, --protocol STRING"
    print "                 Specify which protocol to use to connect to the remote host."
    print "                 STRING is one of: telnet ssh"
    print "                 The default protocol is telnet."
    print "  -v, --verbose NUM"
    print "                 Print out debug information about the network activity."
    print "                 NUM is a number between 0 (min) and 5 (max)"
    print "  -V, --parser-verbose NUM"
    print "                 Print out debug information about the Exscript parser."
    print "                 NUM is a number between 0 (min) and 5 (max)"
    print "      --version  Prints the version number."
    print "  -h, --help     Prints this help."

# Define default options.
default_options = [
  ('authorize',         'a',  False),
  ('authorize2',        'A',  False),
  ('no-echo',           None, False),
  ('connections=',      'c:', 1),
  ('csv-hosts=',        None, None),
  ('define=',           'd:', {'hostname': 'unknown'}),
  ('hosts=',            None, None),
  ('logdir=',           'l:', None),
  ('protocol=',         'p:', 'telnet'),
  ('no-authentication', 'n',  False),
  ('verbose=',          'v:', 0),
  ('parser-verbose=',   'V:', 0),
  ('version',           None, False),
  ('help',              'h',  False)
]

# Parse options.
try:
    options, args = OptionParser.parse_options(sys.argv, default_options)
except:
    usage()
    sys.exit(1)

# Show the help, if requested.
if options['help']:
    usage()
    sys.exit()

# Show the version number, if requested.
if options['version']:
    print "Exscript %s" % __version__
    sys.exit()

# Check command line syntax.
if options['authorize'] and options['authorize2']:
    print "Error: Can't use both, -a and -A switch."
    sys.exit(1)
if options['no-authentication'] and options['authorize']:
    print "Error: Can't use both, -n and -a switch."
    sys.exit(1)
if options['no-authentication'] and options['authorize2']:
    print "Error: Can't use both, -n and -A switch."
    sys.exit(1)

try:
    exscript  = args.pop(0)
    hostnames = args
except:
    usage()
    sys.exit(1)
defines = dict([(hostname, options['define']) for hostname in hostnames])

{'fraction_non_alphanumeric': 0.10772706732941709, 'fraction_numerical': 0.007410754631721645, 'mean_word_length': 1.9159420289855071, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '5161634', 'n_tokens_mistral': 3073, 'n_tokens_neox': 2960, 'n_words': 1206}