<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-

import os
import sys
import logging

logging.basicConfig(filename='/home/brandon/py-obfsproxy/pyobfslog.txt'
                    , loglevel=logging.DEBUG)
logging.error('py-obfsproxy CLI loaded')
logging.error('argv: ' + str(sys.argv))

import argparse

sys.path.insert(0,
                os.path.realpath(os.path.join(os.path.dirname(__file__),
                '../../Dust/py')))
sys.path.insert(0,
                os.path.realpath(os.path.join(os.path.dirname(__file__),
                '../../pyptlib/src')))

from pyptlib.easy.util import checkClientMode

try:
  from obfsproxy.framework.managed.server import ManagedServer
  from obfsproxy.framework.managed.client import ManagedClient
except Exception as e:
  logging.error('Error loading framework: '+str(e))

protocols = ['dummy', 'rot13']

if __name__ == '__main__':
    parser = \
        argparse.ArgumentParser(description='* Available protocols: '
                                + ' '.join(protocols))
    parser.add_argument('--log-file', nargs=1, help='set logfile')
    parser.add_argument('--log-min-severity', nargs=1, default='notice'
                        , choices=['warn', 'notice', 'info', 'debug'],
                        help='set minimum logging severity (default: %(default)s)'
                        )
    parser.add_argument('--no-log', action='store_false', default=True,
                        help='disable logging')
    parser.add_argument('--no-safe-logging', action='store_false',
                        default=True,
                        help='disable safe (scrubbed address) logging')
    parser.add_argument('--managed', action='store_true',
                        default=False,
                        help='enabled managed mode, for use when called by tor'
                        )

#    parser.add_argument('--dest', nargs=1,
#                        help='set destination, enable client mode instead of server mode'
#                        )

#    parser.add_argument('obfsproxy_args')
#    parser.add_argument('protocol_name')
#    parser.add_argument('protocol_args')
#    parser.add_argument('protocol_options')
#    parser.add_argument('protocol_name')

    try:
        args = parser.parse_args()
    except Exception, e:
        logging.error('Exception parsing')
        logging.error(str(e))

#    if args.log_file and len(args.log_file)>0:
# ....print('file logging: '+str(args.log_file[0]))
#        logging.basicConfig(filename=args.log_file[0])

    logging.error('py-obfsproxy CLI loaded')

    daemon = None
    if args.managed:
        if checkClientMode():
            logging.error('client')
            daemon = ManagedClient()
        else:
            logging.error('server')
            daemon = ManagedServer()
    else:
        logging.error('Unsupported mode. Only managed mode is available at the moment.'
                      )

#        if dest:
#            daemon = ExternalClient()
#        else:
#            daemon = ExternalServer()<commit_msg>Commented out logging<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-

import os
import sys
import logging

logging.basicConfig(filename='/home/brandon/py-obfsproxy/pyobfslog.txt', loglevel=logging.DEBUG)
logging.error('py-obfsproxy CLI loaded')
logging.error('argv: ' + str(sys.argv))

import argparse

sys.path.insert(0,
                os.path.realpath(os.path.join(os.path.dirname(__file__),
                '../../Dust/py')))
sys.path.insert(0,
                os.path.realpath(os.path.join(os.path.dirname(__file__),
                '../../pyptlib/src')))

from pyptlib.easy.util import checkClientMode

try:
  from obfsproxy.framework.managed.server import ManagedServer
  from obfsproxy.framework.managed.client import ManagedClient
except Exception as e:
  logging.error('Error loading framework: '+str(e))

protocols = ['dummy', 'rot13']

if __name__ == '__main__':
    parser = \
        argparse.ArgumentParser(description='* Available protocols: '
                                + ' '.join(protocols))
    parser.add_argument('--log-file', nargs=1, help='set logfile')
    parser.add_argument('--log-min-severity', nargs=1, default='notice'
                        , choices=['warn', 'notice', 'info', 'debug'],
                        help='set minimum logging severity (default: %(default)s)'
                        )
    parser.add_argument('--no-log', action='store_false', default=True,
                        help='disable logging')
    parser.add_argument('--no-safe-logging', action='store_false',
                        default=True,
                        help='disable safe (scrubbed address) logging')
    parser.add_argument('--managed', action='store_true',
                        default=False,
                        help='enabled managed mode, for use when called by tor'
                        )

#    parser.add_argument('--dest', nargs=1,
#                        help='set destination, enable client mode instead of server mode'
#                        )

#    parser.add_argument('obfsproxy_args')
#    parser.add_argument('protocol_name')
#    parser.add_argument('protocol_args')
#    parser.add_argument('protocol_options')
#    parser.add_argument('protocol_name')

    try:
        args = parser.parse_args()
    except Exception, e:
        logging.error('Exception parsing')
        logging.error(str(e))

    if args.log_file and len(args.log_file)>0:
      logging.error('file logging: '+str(args.log_file[0])+' '+str(os.path.exists(args.log_file[0])))
      logging.config.fileConfig(str(args.log_file[0]), disable_existing_loggers=False)
      logging.error('new logging in place')

    logging.error('py-obfsproxy CLI loaded')

    daemon = None
    if args.managed:
        if checkClientMode():
            logging.error('client')
            daemon = ManagedClient()
        else:
            logging.error('server')
            daemon = ManagedServer()
    else:
        logging.error('Unsupported mode. Only managed mode is available at the moment.'
                      )
{'fraction_non_alphanumeric': 0.13381555153707053, 'fraction_numerical': 0.0037810290974847937, 'mean_word_length': 2.286871961102107, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5230404', 'n_tokens_mistral': 1772, 'n_tokens_neox': 1710, 'n_words': 330}