Example #1
0
def launch(nodaemon):
    sys.path.insert(0, os.path.abspath(os.getcwd()))

    # see if we can launch the application without actually having to
    # spawn twistd, since spawning processes correctly is a real hassle
    # on windows.
    from twisted.python.runtime import platformType
    argv = [
        "twistd",
        "--no_save",
        "--logfile=twistd.log",  # windows doesn't use the same default
        "--python=buildbot.tac"
    ]
    if nodaemon:
        argv.extend(['--nodaemon'])
    sys.argv = argv

    # this is copied from bin/twistd. twisted-2.0.0 through 2.4.0 use
    # _twistw.run . Twisted-2.5.0 and later use twistd.run, even for
    # windows.
    from twisted import __version__
    major, minor, ignored = __version__.split(".", 2)
    major = int(major)
    minor = int(minor)
    if (platformType == "win32" and (major == 2 and minor < 5)):
        from twisted.scripts import _twistw
        run = _twistw.run
    else:
        from twisted.scripts import twistd
        run = twistd.run
    run()
Example #2
0
def launch(nodaemon):
    sys.path.insert(0, os.path.abspath(os.getcwd()))

    # see if we can launch the application without actually having to
    # spawn twistd, since spawning processes correctly is a real hassle
    # on windows.
    from twisted.python.runtime import platformType
    argv = ["twistd",
            "--no_save",
            "--logfile=twistd.log",  # windows doesn't use the same default
            "--python=buildbot.tac"]
    if nodaemon:
        argv.extend(["--nodaemon"])
        if platformType != 'win32':
            # windows doesn't use pidfile option.
            argv.extend(["--pidfile="])

    sys.argv = argv

    # this is copied from bin/twistd. twisted-2.0.0 through 2.4.0 use
    # _twistw.run . Twisted-2.5.0 and later use twistd.run, even for
    # windows.
    from twisted import __version__
    major, minor, ignored = __version__.split(".", 2)
    major = int(major)
    minor = int(minor)
    if (platformType == "win32" and (major == 2 and minor < 5)):
        from twisted.scripts import _twistw
        run = _twistw.run
    else:
        from twisted.scripts import twistd
        run = twistd.run
    run()
Example #3
0
def launch(config):
    sys.path.insert(0, os.path.abspath(os.getcwd()))
    if os.path.exists("/usr/bin/make") and os.path.exists("Makefile.buildbot"):
        # Preferring the Makefile lets slave admins do useful things like set
        # up environment variables for the buildslave.
        cmd = "make -f Makefile.buildbot start"
        if not config['quiet']:
            print cmd
        os.system(cmd)
    else:
        # see if we can launch the application without actually having to
        # spawn twistd, since spawning processes correctly is a real hassle
        # on windows.
        from twisted.python.runtime import platformType
        argv = ["twistd",
                "--no_save",
                "--logfile=twistd.log", # windows doesn't use the same default
                "--python=buildbot.tac"]
        sys.argv = argv

        # this is copied from bin/twistd. twisted-2.0.0 through 2.4.0 use
        # _twistw.run . Twisted-2.5.0 and later use twistd.run, even for
        # windows.
        from twisted import __version__
        major, minor, ignored = __version__.split(".", 2)
        major = int(major)
        minor = int(minor)
        if (platformType == "win32" and (major == 2 and minor < 5)):
            from twisted.scripts import _twistw
            run = _twistw.run
        else:
            from twisted.scripts import twistd
            run = twistd.run
        run()
Example #4
0
##    but WITHOUT ANY WARRANTY; without even the implied warranty of
##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##    GNU General Public License for more details.
##
##    You should have received a copy of the GNU General Public License
##    along with this program.  If not, see <http://www.gnu.org/licenses/>.
##

twistedversion = '1'
try:
    from twisted import __version__ as twistedversion
except ImportError:
    #assume a pre-2.0 version of Twisted
    from twisted.protocols import irc

twistedmajor = int(twistedversion.split('.')[0])

if twistedmajor >= 2:
    from twisted.words.protocols import irc

from twisted.internet import reactor, protocol, task

import sys
import time
import threading

from contrib.configobj import ConfigObj, ConfigObjError

from pyGBot import log
from pyGBot.PluginEvents import PluginEvents
from twisted import __version__
__TW_VER__ = tuple([int(x) for x in __version__.split('.')])

if __TW_VER__ > (13, 0, 0):
	from twisted.web import client
	from twisted.internet import endpoints
	from twisted.web.iweb import IBodyProducer

elif __TW_VER__ >= (11, 1, 0):
	import tx
	from tx import client
	from tx import endpoints
	from tx.iweb import IBodyProducer
else:
	raise Exception("No HTTP 1.1 Support")

try:
	from OpenSSL import SSL
	from twisted.internet.ssl import ClientContextFactory
except:
	twAgent = False
	raise Exception("No SSL Support")
else:
	twAgent = True

try:
	from urlparse import urlunparse, urljoin, urldefrag
	from urllib import splithost, splittype
except ImportError:
	from urllib.parse import splithost, splittype, urljoin, urldefrag
Example #6
0
# mirrors gameclient/clientcode/SPHTTP.js


def unwrap_string(input):
    return unicode(base64.b64decode(str(input)).decode('utf-8'))


def wrap_string(input):
    return base64.b64encode(input.encode('utf-8'))


# below functions are specific to Twisted

from twisted import __version__ as twisted_version

twisted_major_version = int(twisted_version.split('.')[0])
from twisted.web.server import NOT_DONE_YET
from twisted.web.http import INTERNAL_SERVER_ERROR
from twisted.python.failure import Failure


# set cross-site allow headers on Twisted HTTP requests
def _set_access_control_headers(request, origin, max_age):
    if origin:
        request.setHeader('Access-Control-Allow-Origin', origin)
    request.setHeader('Access-Control-Allow-Credentials', 'true')
    request.setHeader('Access-Control-Allow-Methods',
                      'POST, GET, HEAD, OPTIONS')
    request.setHeader('Access-Control-Allow-Headers', 'X-Requested-With')
    if max_age >= 0:
        request.setHeader('Access-Control-Max-Age', str(max_age))
Example #7
0
from twisted import __version__

tmp = tuple([x for x in __version__.split('.')])
__TW_VER__ = []
for x in tmp:
    __TW_VER__.append(int(''.join([i for i in x if i.isdigit()])))
del tmp

import mp_globals
import sys
try:
    from enigma import eMediaDatabase
    mp_globals.isDreamOS = True
except:
    mp_globals.isDreamOS = False
if __TW_VER__ >= [14, 0, 0]:
    if mp_globals.isDreamOS:
        mp_globals.requests = False
    elif sys.version_info[:3] >= (2, 7, 9):
        mp_globals.requests = False
    else:
        mp_globals.requests = True
else:
    mp_globals.requests = True

if __TW_VER__ > [13, 0, 0]:
    from twisted.web import client
    from twisted.internet import endpoints
    from twisted.web.iweb import IBodyProducer

elif __TW_VER__ >= [11, 1, 0]:
Example #8
0
##    but WITHOUT ANY WARRANTY; without even the implied warranty of
##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##    GNU General Public License for more details.
##
##    You should have received a copy of the GNU General Public License
##    along with this program.  If not, see <http://www.gnu.org/licenses/>.
##

twistedversion = '1'
try:
    from twisted import __version__ as twistedversion
except ImportError:
    #assume a pre-2.0 version of Twisted
    from twisted.protocols import irc

twistedmajor = int(twistedversion.split('.')[0])

if twistedmajor >= 2:
    from twisted.words.protocols import irc

from twisted.internet import reactor, protocol, task

import sys
import time
import threading

from contrib.configobj import ConfigObj, ConfigObjError

from pyGBot import log
from pyGBot.PluginEvents import PluginEvents
Example #9
0
#	-*-	coding:	utf-8	-*-


import base64
from twisted import __version__
__TW_VER__ = tuple([int(x) for x in __version__.split('.')])

try:
	from twisted.internet.endpoints import TCP4ClientEndpoint
except:
	twEndpoints = False
	print 'Error: twisted endpoints not imported'
else:
	twEndpoints = True
	
from twisted.web.client import Agent, RedirectAgent, getPage, ProxyAgent
from twisted.internet import reactor
from twisted.web.http_headers import Headers
from twisted.internet.protocol import Protocol
from twisted.internet.defer import Deferred
from twisted.web import http
from urlparse import urlunparse

agent_headers = {
	#'User-Agent': ['Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.6) Gecko/20100627 Firefox/3.6.6'],
	#'Accept-Charset': ['ISO-8859-1,utf-8;q=0.7,*;q=0.7'],
	#'Accept': ['text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'],
	#'Accept-Language': ['en-us,en;q=0.5'],
	'Content-Type': ['application/x-www-form-urlencoded']
}