コード例 #1
0
class ThreadSafeList:
    """
	In Jython 2.1 lists aren't thread-safe, so this wraps it.  Newer versions
	of Jython are completely different than 2.1, so this class is deprecated
	to make way for future versions of Jython.
	"""

    deprecatedModuleAttribute(
        Version("Twisted", 10, 1, 0),
        "This was an internal implementation detail of support for Jython 2.1,"
        " which is now obsolete.", __name__, "ThreadSafeList")

    def __init__(self):
        self.lock = threading.Lock()
        self.l = []

    def append(self, i):
        self.lock.acquire()
        try:
            self.l.append(i)
        finally:
            self.lock.release()

    def remove(self, i):
        self.lock.acquire()
        try:
            self.l.remove(i)
        finally:
            self.lock.release()

    def __len__(self):
        return len(self.l)
コード例 #2
0
	def main(self, args):
		"""
		Given a list of command-line arguments, change all the Twisted versions
		in the current directory.

		@type args: list of str
		@param args: List of command line arguments.  This should only
			contain the version number.
		"""
		version_format = (
			"Version should be in a form kind of like '1.2.3[pre4]'")
		if len(args) != 1:
			sys.exit("Must specify exactly one argument to change-versions")
		version = args[0]
		try:
			major, minor, micro_and_pre = version.split(".")
		except ValueError:
			raise SystemExit(version_format)
		if "pre" in micro_and_pre:
			micro, pre = micro_and_pre.split("pre")
		else:
			micro = micro_and_pre
			pre = None
		try:
			major = int(major)
			minor = int(minor)
			micro = int(micro)
			if pre is not None:
				pre = int(pre)
		except ValueError:
			raise SystemExit(version_format)
		version_template = Version("Whatever",
								   major, minor, micro, prerelease=pre)
		self.changeAllProjectVersions(FilePath("."), version_template)
コード例 #3
0
def changeAllProjectVersions(root, versionTemplate, today=None):
	"""
	Change the version of all projects (including core and all subprojects).

	If the current version of a project is pre-release, then also change the
	versions in the current NEWS entries for that project.

	@type root: L{FilePath}
	@param root: The root of the Twisted source tree.
	@type versionTemplate: L{Version}
	@param versionTemplate: The version of all projects.  The name will be
		replaced for each respective project.
	@type today: C{str}
	@param today: A YYYY-MM-DD formatted string. If not provided, defaults to
		the current day, according to the system clock.
	"""
	if not today:
		today = date.today().strftime('%Y-%m-%d')
	for project in findTwistedProjects(root):
		if project.directory.basename() == "twisted":
			packageName = "twisted"
		else:
			packageName = "lib.twisted." + project.directory.basename()
		oldVersion = project.getVersion()
		newVersion = Version(packageName, versionTemplate.major,
							 versionTemplate.minor, versionTemplate.micro,
							 prerelease=versionTemplate.prerelease)

		if oldVersion.prerelease:
			builder = NewsBuilder()
			builder._changeNewsVersion(
				root.child("NEWS"), builder._getNewsName(project),
				oldVersion, newVersion, today)
			builder._changeNewsVersion(
				project.directory.child("topfiles").child("NEWS"),
				builder._getNewsName(project), oldVersion, newVersion,
				today)

		# The placement of the top-level README with respect to other files (eg
		# _version.py) is sufficiently different from the others that we just
		# have to handle it specially.
		if packageName == "twisted":
			_changeVersionInFile(
				oldVersion, newVersion, root.child('README').path)

		project.updateVersion(newVersion)
コード例 #4
0
def getNextVersion(version, now=None):
	"""
	Calculate the version number for a new release of Twisted based on
	the previous version number.

	@param version: The previous version number.
	@param now: (optional) The current date.
	"""
	# XXX: This has no way of incrementing the patch number. Currently, we
	# don't need it. See bug 2915. Jonathan Lange, 2007-11-20.
	if now is None:
		now = date.today()
	major = now.year - VERSION_OFFSET
	if major != version.major:
		minor = 0
	else:
		minor = version.minor + 1
	return Version(version.package, major, minor, 0)
コード例 #5
0
class IReactorArbitrary(Interface):
    """
	This interface is redundant with L{IReactorFDSet} and is deprecated.
	"""
    deprecatedModuleAttribute(Version("Twisted", 10, 1,
                                      0), "See IReactorFDSet.", __name__,
                              "IReactorArbitrary")

    def listenWith(portType, *args, **kw):
        """
		Start an instance of the given C{portType} listening.

		@type portType: type which implements L{IListeningPort}

		@param portType: The object given by C{portType(*args, **kw)} will be
						 started listening.

		@return: an object which provides L{IListeningPort}.
		"""

    def connectWith(connectorType, *args, **kw):
        """
コード例 #6
0
ファイル: sip.py プロジェクト: samis/blockBox
    m.update(pszRealm)
    m.update(":")
    m.update(pszPassword)
    HA1 = m.digest()
    if pszAlg == "md5-sess":
        m = md5()
        m.update(HA1)
        m.update(":")
        m.update(pszNonce)
        m.update(":")
        m.update(pszCNonce)
        HA1 = m.digest()
    return HA1.encode('hex')


DigestCalcHA1 = deprecated(Version("Twisted", 9, 0, 0))(DigestCalcHA1)


def DigestCalcResponse(
    HA1,
    pszNonce,
    pszNonceCount,
    pszCNonce,
    pszQop,
    pszMethod,
    pszDigestUri,
    pszHEntity,
):
    m = md5()
    m.update(pszMethod)
    m.update(":")
コード例 #7
0
ファイル: util.py プロジェクト: samis/blockBox
# -*- test-case-name: lib.twisted.test.test_enterprise -*-
# Copyright (c) 2001-2008 Twisted Matrix Laboratories.
# See LICENSE for details.

import warnings, types

from lib.twisted.python.versions import Version, getVersionString
from lib.twisted.python.deprecate import deprecated
from lib.twisted.enterprise.adbapi import _safe

# Common deprecation decorator used for all deprecations.
_deprecatedVersion = Version("Twisted", 8, 0, 0)
_releasedDeprecation = deprecated(_deprecatedVersion)

warnings.warn("lib.twisted.enterprise.util is deprecated since %s." %
              (getVersionString(_deprecatedVersion), ),
              category=DeprecationWarning)

NOQUOTE = 1
USEQUOTE = 2

dbTypeMap = {
    "bigint": NOQUOTE,
    "bool": USEQUOTE,
    "boolean": USEQUOTE,
    "bytea": USEQUOTE,
    "date": USEQUOTE,
    "int2": NOQUOTE,
    "int4": NOQUOTE,
    "int8": NOQUOTE,
    "int": NOQUOTE,
コード例 #8
0
ファイル: reflect.py プロジェクト: samis/blockBox
    sys.modules[tprmm] = mymod
    setattr(macros, macroname, mymod)
    dict = mymod.__dict__

    # Before we go on, I guess I should explain why I just did that.  Basically
    # it's a gross hack to get epydoc to work right, but the general idea is
    # that it will be a useful aid in debugging in _any_ app which expects
    # sys.modules to have the same globals as some function.  For example, it
    # would be useful if you were foolishly trying to pickle a wrapped function
    # directly from a class that had been hooked.

    exec code in dict, dict
    return dict[name]


macro = deprecated(Version("Twisted", 8, 2, 0))(macro)


def _determineClass(x):
    try:
        return x.__class__
    except:
        return type(x)


def _determineClassName(x):
    c = _determineClass(x)
    try:
        return c.__name__
    except:
        try:
コード例 #9
0
ファイル: adbapi.py プロジェクト: samis/blockBox
            'min': self.min,
            'max': self.max,
            'noisy': self.noisy,
            'reconnect': self.reconnect,
            'good_sql': self.good_sql,
            'connargs': self.connargs,
            'connkw': self.connkw
        }

    def __setstate__(self, state):
        self.__dict__ = state
        self.__init__(self.dbapiName, *self.connargs, **self.connkw)


# Common deprecation decorator used for all deprecations.
_unreleasedVersion = Version("Twisted", 8, 0, 0)
_unreleasedDeprecation = deprecated(_unreleasedVersion)


def _safe(text):
    """
	Something really stupid that replaces quotes with escaped quotes.
	"""
    return text.replace("'", "''").replace("\\", "\\\\")


def safe(text):
    """
	Make a string safe to include in an SQL statement.
	"""
    return _safe(text)
コード例 #10
0
    """
	Emitted when L{IReactorProcess.spawnProcess} is called in a way which may
	result in termination of the created child process not being reported.

	Deprecated in Twisted 10.0.
	"""
    MESSAGE = ("spawnProcess called, but the SIGCHLD handler is not "
               "installed. This probably means you have not yet "
               "called reactor.run, or called "
               "reactor.run(installSignalHandler=0). You will probably "
               "never see this process finish, and it may become a "
               "zombie process.")


deprecate.deprecatedModuleAttribute(
    Version("Twisted", 10, 0,
            0), "There is no longer any potential for zombie process.",
    __name__, "PotentialZombieWarning")


class ProcessDone(ConnectionDone):
    """A process has ended without apparent errors"""
    def __init__(self, status):
        Exception.__init__(self, "process finished with exit code 0")
        self.exitCode = 0
        self.signal = None
        self.status = status


class ProcessTerminated(ConnectionLost):
    """A process has ended with a probable error condition"""
    def __init__(self, exitCode=None, signal=None, status=None):