Пример #1
0
 def start(self):
   self.app = wx.App(False)
   win   = wx.Frame(None, wx.ID_ANY, _('SecPass v{}', asset.version('secpass-gui')))
   panel = wx.Panel(win)
   text  = wx.StaticText(panel, label=_('SecPass GUI is under active development.'), pos=(40,30))
   win.Show(True)
   self.app.MainLoop()
Пример #2
0
  def __init__(self, principal, credential, env=Environment.PROD, root=None):
    '''
    Constructs a new `canarymd.Client` object that is used to
    communicate with the Canary API. The following parameterns
    are accepted:

    :Parameters:

    principal : str

      The principal (i.e. username) to authenticate with to the Canary
      servers.

    credential : str

      The `principal` 's credential/token (i.e. password) to use to
      authenticate with the Canary servers.

    env : str, optional, default: canarymd.Environment.PROD

      The Canary environment to connect to -- defaults to the
      production servers. For testing, the staging environment
      should be used, i.e. ``canarymd.Environment.STG``.

    '''
    if env not in Environment.ALL:
      raise ValueError('invalid/unknown environment: %r' % (env,))
    self.cookies    = {}
    self.env        = env
    self.root       = root or {
      Environment.PROD : 'https://api.canary.md/api',
      Environment.DEV  : 'http://api-dev.canary.md:8899/api',
    }.get(env,           'https://api-{env}.canary.md/api').format(env=env)
    self.principal  = None
    self.credential = None
    self.session    = None
    self.updateAuth(principal, credential)
    self._version   = aadict(client=asset.version('canarymd'))
    self._checkVersion()
Пример #3
0
def version():
    """Return the current application version."""
    return asset.version('ExperimentSupportSystem')
Пример #4
0
def version():
    """Return the current version number."""
    return asset.version('WebTeachingEnvironment')
Пример #5
0
Файл: test.py Проект: jlec/asset
 def test_version(self):
   self.assertRegexpMatches(asset.version('pxml'), r'^\d+.\d+.\d+$')
Пример #6
0
#       horrific. refactor!

import sys, os, logging, traceback, operator, yaml, re, asset
import pkg_resources, setuptools, setuptools.package_index
import templatealchemy as ta
from aadict import aadict
from asset import isstr, symbol

from . import util, api
from .revinfo import FilteredRevisionInfo
from .util import asList, str2sym, autoresolve, flatten

#------------------------------------------------------------------------------

defaultOptions = util.getResourceString('options.yaml')
version = asset.version('svnpublish')

#------------------------------------------------------------------------------
class SourceRegistry(object):
  def __init__(self):
    self.sources = dict()
  def register(self, name, factory):
    self.sources[name] = factory
  def get(self, name):
    if name not in self.sources:
      raise api.UnknownConfigSource(name)
    return self.sources[name]
sources = SourceRegistry()

#------------------------------------------------------------------------------
class ConfigSourceSvn(api.ConfigSource):
Пример #7
0
def version():
    """Return the current application version."""
    return asset.version('WebTeachingEnvironment')
Пример #8
0
def main(argv=None):

  cli = argparse.ArgumentParser(
    description='A simple, logging, colorizing, prettifying, HTTP proxy.',
  )

  cli.add_argument(
    _('--version'),
    dest='version', action='version',
    version='%(prog)s/' + asset.version('proxylog'))

  cli.add_argument(
    _('-v'), _('--verbose'),
    dest='verbose', default=0, action='count',
    help=_('enable verbose output to STDERR (multiple'
           ' invocations increase verbosity)'))

  # cli.add_argument(
  #   _('--ssl'),
  #   dest='ssl', default=False, action='store_true',
  #   help=_('upgrade outbound requests to HTTPS'))

  cli.add_argument(
    _('-p'), _('--port'), metavar=_('PORT'),
    dest='local', default=80, action='store', type=int,
    help=_('specify the local port to listen on for new'
           ' connections'))

  cli.add_argument(
    _('-r'), _('--remote'), metavar=_('HOSTPORT'),
    dest='remote', default=None, action='store',
    help=_('specify the remote server and optionally port (e.g.'
           ' "host" or "host:port")'))

  # cli.add_argument(
  #   _('-H'), _('--rewrite-host'),
  #   dest='rewriteHost', default=False, action='store_true',
  #   help=_('(TODO: IMPLEMENT) rewrite the outbound HTTP "Host"'
  #          ' header, if present, to that specified by --remote'))

  cli.add_argument(
    _('-s'), _('--response-sed'), metavar=_('SED-EXPR'),
    dest='responseSed', default=[], action='append',
    help=_('use sed-like transformation of the response body'))

  cli.add_argument(
    _('-o'), _('--output'), metavar=_('FILENAME'),
    dest='outfile', default=None, action='store',
    help=_('store all transactions to the specified file'
           ' in binary format so that it can later be replayed'
           ' with --input'))

  cli.add_argument(
    _('-a'), _('--append'), metavar=_('FILENAME'),
    dest='appfile', default=None, action='store',
    help=_('same as "--output", but append to the current'
           ' content, if the file exists'))

  cli.add_argument(
    _('-i'), _('--input'), metavar=_('FILENAME'),
    dest='infile', default=None, action='store',
    help=_('replay previous transactions recorded with'
           ' "--output" (implies "--display")'))

  cli.add_argument(
    _('-d'), _('--display'),
    dest='display', default=False, action='store_true',
    help=_('display all transactions to STDOUT in human-'
           'readable form'))

  cli.add_argument(
    _('-c'), _('--color'),
    dest='color', default=False, action='store_true',
    help=_('use terminal color codes to differentiate HTTP'
           ' headers, content, requests and responses'
           ' (implies "--display")'))

  cli.add_argument(
    _('-t'), _('--theme'), metavar=_('NAME'),
    dest='theme', default=None, action='store',
    help=_('overrides the default color theme; can be any of the'
           ' styles supported by Pygments (implies "--color")'))

  cli.add_argument(
    _('-u'), _('--uncompress'),
    dest='uncompress', default=False, action='store_true',
    help=_('uncompress body data (if compressed) before'
           ' displaying it (implies "--display")'))

  cli.add_argument(
    _('-f'), _('--format'),
    dest='format', default=False, action='store_true',
    help=_('turns on format prettification of known formats'
           ' including XML, YAML, and JSON (implies'
           ' "--uncompress" and "--display")'))

  cli.add_argument(
    _('-b'), _('--breaklines'), metavar=_('COUNT'),
    dest='breaklines', default=60, type=int,
    help=_('number of lines to output to STDOUT when ^D'
           ' (Control-D) is pressed'))

  #----------------------------------------------------------------------------

  options = cli.parse_args(argv)

  if not options.remote and not options.infile:
    cli.error(_('please specify the remote server ("--remote") or input'
                ' file ("--input")'))

  if options.appfile and options.outfile:
    cli.error(_('only one of "--output" or "--append" can be specified'))

  if options.remote and options.infile:
    cli.error(_('only one of "--remote" or "--input" can be specified'))

  options.responseSed = [parseSedExpression(expr)
                         for expr in options.responseSed]

  # convert options to a dict
  options = aadict(morph.omit(options))

  #----------------------------------------------------------------------------

  rootlog = logging.getLogger()
  rootlog.setLevel(logging.ERROR)
  handler = logging.StreamHandler()
  handler.setFormatter(LogFmt())
  rootlog.addHandler(handler)
  if options.verbose == 1    : rootlog.setLevel(logging.INFO)
  elif options.verbose == 2  : rootlog.setLevel(logging.DEBUG)
  elif options.verbose > 2   : rootlog.setLevel(1)

  #----------------------------------------------------------------------------

  if options.infile:
    options.display = True
    if options.infile == '-':
      options.infile = sys.stdin
      log.info('replaying transactions from <STDIN>')
    else:
      log.info('replaying transactions from "%s"', options.infile)
      options.infile = open(options.infile, 'rb')
      atexit.register(options.infile.close)
    server = ReplayServer(options, options.infile)
  else:
    # port = options.ssl and 443 or 80
    port = 80
    if options.remote.find(':') >= 0:
      options.remote, port = options.remote.split(':', 1)
      port = int(port)
    options.remote = (options.remote, port)
    options.local = ('localhost', options.local)
    server = BaseHTTPServer.HTTPServer(options.local, LoggingRequestHandler)
    log.info('accepting connections on %s:%r', *options.local)

  server.options = options
  server.logger  = MultiLogger()

  if options.format:
    options.uncompress = True

  if options.theme:
    options.color = True

  if options.color or options.uncompress:
    options.display = True

  options.markup = getDefaultMarkup(options.color)

  append = False
  if options.appfile:
    options.outfile = options.appfile
    append = True

  if options.outfile:
    if options.outfile == '-':
      server.logger.loggers.append(StreamLogger(sys.stdout, options=options))
    else:
      fstream = open(options.outfile, 'ab' if append else 'wb')
      server.logger.loggers.append(StreamLogger(fstream, options=options))
      atexit.register(fstream.close)

  if options.display:
    server.logger.loggers.append(DisplayLogger(sys.stdout, options=options))

  if not ( options.infile or options.outfile or options.display ):
    log.warn('no logging/displaying configured - acting as a simple proxy')

  try:
    if not options.infile:
      t = threading.Thread(target=breaklines, args=(options,))
      t.daemon = True
      t.start()
    server.serve_forever()
  except KeyboardInterrupt:
    log.info('aborted by user - exiting')

  return 0
Пример #9
0
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#------------------------------------------------------------------------------
'''
The ``pysyncml.common`` package provides some commonly used helper routines
and classes used throughout the pysyncml package.
'''

import sys, time, calendar, inspect, six, pkg_resources, platform
import xml.etree.ElementTree as ET
import asset

from . import constants

#------------------------------------------------------------------------------
version = asset.version('pysyncml')


#------------------------------------------------------------------------------
class SyncmlError(Exception):
    pass


class ProtocolError(SyncmlError):
    pass


class InternalError(SyncmlError):
    pass

Пример #10
0
 def test_version(self):
     self.assertRegexpMatches(asset.version('pxml'), r'^\d+.\d+.\d+$')
Пример #11
0
# along with this program. If not, see http://www.gnu.org/licenses/.
#------------------------------------------------------------------------------

'''
The ``pysyncml.common`` package provides some commonly used helper routines
and classes used throughout the pysyncml package.
'''

import sys, time, calendar, inspect, six, pkg_resources, platform
import xml.etree.ElementTree as ET
import asset

from . import constants

#------------------------------------------------------------------------------
version = asset.version('pysyncml')

#------------------------------------------------------------------------------
class SyncmlError(Exception): pass
class ProtocolError(SyncmlError): pass
class InternalError(SyncmlError): pass
class ConflictError(SyncmlError): pass
class FeatureNotSupported(SyncmlError): pass
class LogicalError(SyncmlError): pass
class InvalidContext(SyncmlError): pass
class InvalidAdapter(SyncmlError): pass
class InvalidStore(SyncmlError): pass
class InvalidContentType(SyncmlError): pass
class InvalidAgent(SyncmlError): pass
class InvalidContent(SyncmlError): pass
class InvalidItem(SyncmlError): pass