rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
if True:
if first:
def init(self, first=False): """ set main things up """ self.parser = XMLParser(join(self.configdir, "gui.xml"), join(self.path, "module", "config", "gui_default.xml")) lang = self.parser.xml.elementsByTagName("language").item(0).toElement().text() if not lang: parser = XMLParser(join(self.path, "module", "config", "gu...
print os.uname()
def main(): print "##### System Information #####" print "" print "Platform:", sys.platform print "Operating System:", os.name print "Python:", sys.version.replace("\n", "") print os.uname() print "" try: import pycurl print "pycurl:", pycurl.version except: print "pycurl:", "missing" try: import Crypto print "py...
"status": fields[4], "shorthost": fields[5], "checksum": fields[6].strip().lower(), "mirror": "http://rs%(serverid)s%(shorthost)s.rapidshare.com/files/%(fileid)s/%(filename)s" % self.api_data}
"status": fields[4], "shorthost": fields[5], "checksum": fields[6].strip().lower()} self.api_data["mirror"] = "http://rs%(serverid)s%(shorthost)s.rapidshare.com/files/%(fileid)s/%(filename)s" % self.api_data
def download_api_data(self, force=False): """ http://images.rapidshare.com/apidoc.txt """ if self.api_data and not force: return api_url_base = "http://api.rapidshare.com/cgi-bin/rsapi.cgi" api_param_file = {"sub": "checkfiles_v1", "files": "", "filenames": "", "incmd5": "1", "files": self.id, "filenames": self.name} s...
self.html_old = None
def __init__(self, parent): Plugin.__init__(self, parent) props = {} props['name'] = "RapidshareCom" props['type'] = "hoster" props['pattern'] = r"http://[\w\.]*?rapidshare.com/files/(\d*?)/(.*)" props['version'] = "1.0" props['description'] = """Rapidshare.com Download Plugin""" props['author_name'] = ("spoob", "RaNaN...
self.html_old = time()
def download_html(self): """ gets the url from self.parent.url saves html in self.html and parses """ self.html[0] = self.req.load(self.url, cookies=True) self.html_old = time()
self.html_old = time()
def get_wait_time(self): """downloads html with the important informations """ file_server_url = re.search(r"<form action=\"(.*?)\"", self.html[0]).group(1) self.html[1] = self.req.load(file_server_url, cookies=True, post={"dl.start": "Free"}) self.html_old = time()
self.time_plus_wait = time() + 60 * int(wait_minutes)
self.time_plus_wait = time() + 60 * int(wait_minutes) + 60 self.no_slots = True
def get_wait_time(self): """downloads html with the important informations """ file_server_url = re.search(r"<form action=\"(.*?)\"", self.html[0]).group(1) self.html[1] = self.req.load(file_server_url, cookies=True, post={"dl.start": "Free"}) self.html_old = time()
self.sock.connect((self.getConf("host"), self.getConf("port"))) nick = self.getConf("nick")
host = self.getConfig("host") self.sock.connect((host, self.getConfig("port"))) nick = self.getConfig("nick")
def run(self): # connect to IRC etc. self.sock = socket.socket() self.sock.connect((self.getConf("host"), self.getConf("port"))) nick = self.getConf("nick") self.sock.send("NICK %s\r\n" % nick) self.sock.send("USER %s %s bla :%s\r\n" % (nick, self.getConf("host"), nick)) for t in self.getConf("owner").split(): if t.str...
self.sock.send("USER %s %s bla :%s\r\n" % (nick, self.getConf("host"), nick)) for t in self.getConf("owner").split():
self.sock.send("USER %s %s bla :%s\r\n" % (nick, host, nick)) for t in self.getConfig("owner").split():
def run(self): # connect to IRC etc. self.sock = socket.socket() self.sock.connect((self.getConf("host"), self.getConf("port"))) nick = self.getConf("nick") self.sock.send("NICK %s\r\n" % nick) self.sock.send("USER %s %s bla :%s\r\n" % (nick, self.getConf("host"), nick)) for t in self.getConf("owner").split(): if t.str...
self.log.info("pyLoadIRC: Connected to %s!" % self.host)
self.log.info("pyLoadIRC: Connected to %s!" % host)
def run(self): # connect to IRC etc. self.sock = socket.socket() self.sock.connect((self.getConf("host"), self.getConf("port"))) nick = self.getConf("nick") self.sock.send("NICK %s\r\n" % nick) self.sock.send("USER %s %s bla :%s\r\n" % (nick, self.getConf("host"), nick)) for t in self.getConf("owner").split(): if t.str...
if msg["origin"].split("!", 1)[0] != self.owner: return if msg["target"].split("!", 1)[0] != self.nick:
if not msg["origin"].split("!", 1)[0] in self.getConfig("owner").split(): return if msg["target"].split("!", 1)[0] != self.getConfig("nick"):
def handle_events(self, msg): if msg["origin"].split("!", 1)[0] != self.owner: return if msg["target"].split("!", 1)[0] != self.nick: return if msg["action"] != "PRIVMSG": return # HANDLE CTCP ANTI FLOOD/BOT PROTECTION if msg["text"] == "\x01VERSION\x01": self.log.debug("Sending CTCP VERSION.") self.sock.send("NOTIC...
for t in self.getConf("owner").split():
for t in self.getConfig("owner").split():
def response(self, msg, origin=""): if origin == "": for t in self.getConf("owner").split(): self.sock.send("PRIVMSG %s :%s\r\n" % (t.strip(), msg)) else: self.sock.send("PRIVMSG %s :%s\r\n" % (origin.split("!", 1)[0], msg))
self.occ_plugins.remove(pyfile.modul.__name__)
self.occ_plugins.remove(pyfile.plugin.__name__)
def jobFinished(self, pyfile): """manage completing download""" self.lock.acquire()
p = os.path.relpath(path)
p = relpath(path)
def path_make_relative(path): p = os.path.relpath(path) if p[-1] == os.path.sep: return p else: return p + os.path.sep
size = re.search(r'<span style="float: left;"><strong>(.*?) MB</strong>', html).group(1) size = int(float(size)*1024*1024)
def getInfo(urls): result = [] for url in urls: html = getURL(url) if re.search(r'<h1>File not available</h1>', html): result.append((url, 0, 1, url)) continue size = re.search(r'<span style="float: left;"><strong>(.*?) MB</strong>', html).group(1) size = int(float(size)*1024*1024) name = re.search('<h1>(.*?)<br/></...
try: self.setWait(int(wait)+3) except: self.setWait(int(wait[-2:]))
wait = wait.decode("UTF-8").encode("ascii", "ignore") self.setWait(int(wait)+3)
def handleFree(self): if r'<div id="captchaArea" style="display:none;">' in self.html or \ r'/showCaptcha\(\);' in self.html: # we got a captcha id = re.search(r"var reCAPTCHA_publickey='(.*?)';", self.html).group(1) recaptcha = ReCaptcha(self) challenge, code = recaptcha.challenge(id) shortencode = re.search(r'name=...
self.req = pyfile.m.core.requestFactory.getRequest(self.__name__)
def __init__(self, pyfile): self.config = pyfile.m.core.config self.core = pyfile.m.core
langNode = self.parser.xml.elementsByTagName("language").item(0).toElement() translation = gettext.translation("pyLoadGui", join(dirname(__file__), "locale"), languages=[str(langNode.text())])
lang = self.parser.xml.elementsByTagName("language").item(0).toElement().text() if not lang: parser = XMLParser("module/config/gui_default.xml") lang = parser.xml.elementsByTagName("language").item(0).toElement().text() translation = gettext.translation("pyLoadGui", join(dirname(__file__), "locale"), languages=[str(lan...
def init(self, first=False): """ set main things up """ self.parser = XMLParser("module/config/gui.xml", "module/config/gui_default.xml") langNode = self.parser.xml.elementsByTagName("language").item(0).toElement() translation = gettext.translation("pyLoadGui", join(dirname(__file__), "locale"), languages=[str(langNode...
elif self.config['quality'] == "hq":
elif self.config['quality'] == "hd" and self.hd_available: quality = "&fmt=22" else:
def get_file_url(self): """ returns the absolute downloadable filepath """ if self.html == None: self.download_html()
elif self.config['quality'] == "hd": quality = "&fmt=22"
def get_file_url(self): """ returns the absolute downloadable filepath """ if self.html == None: self.download_html()
down_script = re.search(r'name="down_script" value="(.*?)"', self.html).group(1)
down_script = re.search(r'name="down_script" value="(.*?)"', self.html)
def doDownload(self): """ returns the absolute downloadable filepath """ if self.html is None: self.download_html()
"down_script" : down_script
def doDownload(self): """ returns the absolute downloadable filepath """ if self.html is None: self.download_html()
self.cmd = [join(pypath, "UnRAR.exe")] else: self.cmd = ["unrar"]
self.cmd = join(pypath, "UnRAR.exe") else: self.cmd = "unrar"
def __init__(self, archive, tmpdir=None, ramSize=0, cpu=0): """ archive should be be first or only part """ self.archive = archive self.pattern = None m = re.match("^(.*).part(\d+).rar$", archive) if m: self.pattern = "%s.part*.rar" % m.group(1) else: #old style self.pattern = "%s.r*" % archive.replace(".rar", "") if o...
Popen(["renice", self.cpu, p.pid], stdout=PIPE, bufsize=-1)
Popen(["renice", str(self.cpu), str(p.pid)], stdout=PIPE, stderr=PIPE,bufsize=-1)
def renice(self, p): """ renice process """ if os.name != "nt" and self.cpu: try: Popen(["renice", self.cpu, p.pid], stdout=PIPE, bufsize=-1) except: try: Popen(["busybox", "renice", self.cpu, p.pid], stdout=PIPE, bufsize=-1) except: print "Renice failed"
try: Popen(["busybox", "renice", self.cpu, p.pid], stdout=PIPE, bufsize=-1) except: print "Renice failed"
print "Renice failed"
def renice(self, p): """ renice process """ if os.name != "nt" and self.cpu: try: Popen(["renice", self.cpu, p.pid], stdout=PIPE, bufsize=-1) except: try: Popen(["busybox", "renice", self.cpu, p.pid], stdout=PIPE, bufsize=-1) except: print "Renice failed"
args = self.cmd + ["v"]
args = [self.cmd, "v"]
def listContent(self, password=None): """ returns a list with all infos to the files in the archive dict keys: name, version, method, crc, attributes, time, date, ratio, size_packed, size @return list(dict, dict, ...) """ f = self.archive if self.pattern: f = self.pattern args = self.cmd + ["v"] if password: args.appen...
args = self.cmd + ["t", "-p%s" % password, f]
args = [self.cmd, "t", "-p%s" % password, f]
def checkPassword(self, password, statusFunction=None): """ check if password is okay @return bool """ if not self.needPassword(): return True f = self.archive if self.pattern: f = self.pattern args = self.cmd + ["t", "-p%s" % password, f] try: args.append(self.getSmallestFile(password)["name"]) except WrongPasswordErr...
args = self.cmd
args = [self.cmd]
def extract(self, password=None, fullPath=True, files=[], exclude=[], destination=None, overwrite=False, statusFunction=None): """ extract the archive @return bool: extract okay? raises WrongPasswordError or CommandError """ f = self.archive if self.pattern: f = self.pattern args = self.cmd if fullPath: args.append("x"...
with open("sobiz_dump.html", "w") as f: f.write(self.html)
def downloadHTML(self): self.html = self.load(self.pyfile.url, cookies=True) with open("sobiz_dump.html", "w") as f: f.write(self.html) if not self.account: html = self.load("%s/free/" % self.pyfile.url, post={"dl_free":"1"}, cookies=True) if re.search(r"/failure/full/1", self.req.lastEffectiveURL): self.setWait(120) ...
if line.endswith(":"):
if line.endswith(":") and line.count(":") == 1:
def loadAccounts(self): """loads all accounts available""" if not exists("accounts.conf"): f = open("accounts.conf", "wb") f.write("version: " + str(ACC_VERSION)) f.close() f = open("accounts.conf", "rb") content = f.readlines() version = content.pop(0) version = version.split(":")[1].strip()
if self.do_kill or not self.checkPidFile():
if self.do_kill or (not self.checkPidFile() and not self.daemon):
def start(self, xmlrpc=True, web=True): """ starts the fun :D """ if not exists("pyload.conf"): from module.setup import Setup
print self.server_methods.get_config_data()
def start(self): """ starts the machine"""
remove(f)
remove(dl)
def postCheck(self, dl):
if self.config["permission"]["change_group"]: if os.name != "nt": try: from grp import getgrnam group = getgrnam(self.config["permission"]["group"]) os.setgid(group[2]) except Exception, e: print _("Failed changing group: %s") % e
def start(self, xmlrpc=True, web=True): """ starts the fun :D """
out = subprocess.Popen([join(self.folder, 'download_finished', script), pyfile.plugin.props['name'], pyfile.url, pyfile.status.name, \ join(self.core.path,self.core.config['general']['download_folder'], pyfile.folder, pyfile.status.name)], stdout=subprocess.PIPE)
out = subprocess.Popen([join(self.folder, 'download_finished', script), pyfile.plugin.props['name'], pyfile.url, pyfile.status.filename, \ join(self.core.path,self.core.config['general']['download_folder'], pyfile.folder, pyfile.status.filename)], stdout=subprocess.PIPE)
def downloadFinished(self, pyfile): for script in self.scripts['download_finished']: try: out = subprocess.Popen([join(self.folder, 'download_finished', script), pyfile.plugin.props['name'], pyfile.url, pyfile.status.name, \ join(self.core.path,self.core.config['general']['download_folder'], pyfile.folder, pyfile.statu...
self.occ_plugins.append(pyfile.modul.__name__)
self.occ_plugins.append(pyfile.plugin.__name__)
def getJob(self): """return job if suitable, otherwise send thread idle"""
if pyfile.plugin.props['type'] == "container":
if pyfile.plugin.__type__ == "container":
def isDecryptWaiting(self): pyfiles = self.list.getDownloadList(self.occ_plugins) for pyfile in pyfiles: if pyfile.plugin.props['type'] == "container": return True return False
return str(self._Proxy__subject).replace(os.sep, Sep)
return str(self._subject).replace(os.sep, Sep)
def __str__(self): return str(self._Proxy__subject).replace(os.sep, Sep)
python_expr = _python_.replace('\\', '\\\\') act = TestSCons.re_escape('%s build.py \$foo \$TARGET \$SOURCES' % python_expr)
def build(num, target, source): file = open(str(target), 'wb') file.write('%s\n'%num) for s in source: file.write(open(str(s), 'rb').read())
\tbut they appear to have the same action: %s """ % act) + TestSCons.file_expr
\tbut they appear to have the same action: %s build.py .foo .TARGET .SOURCES """ % _python_) + TestSCons.file_expr
def build(num, target, source): file = open(str(target), 'wb') file.write('%s\n'%num) for s in source: file.write(open(str(s), 'rb').read())
def __init__(self, node):
def __init__(self, node=None):
def __init__(self, node): # Create an object attribute from the class attribute so it ends up # in the pickled data in the .sconsign file. self._version_id = self.current_version_id
def __init__(self, node):
def __init__(self, node=None):
def __init__(self, node): # Create an object attribute from the class attribute so it ends up # in the pickled data in the .sconsign file. self._version_id = self.current_version_id self.bsourcesigs = [] self.bdependsigs = [] self.bimplicitsigs = [] self.bactsig = None
if seen[include[1]] == 1: continue
already_seen = seen[include[1]]
def scan_recurse(self, node, path=()): """ do a recursive scan of the top level target file This lets us search for included files based on the directory of the main file just as latex does"""
assert s == test.workpath('0.out'), s
t = os.path.normcase(test.workpath('0.out')) assert os.path.normcase(s) == t, s
def func(target, source, env): open(str(target[0]), "w") if (len(source) == 1 and len(target) == 1): env['CNT'][0] = env['CNT'][0] + 1
assert s == test.workpath('1.out'), s
t = os.path.normcase(test.workpath('1.out')) assert os.path.normcase(s) == t, s
def func(target, source, env): open(str(target[0]), "w") if (len(source) == 1 and len(target) == 1): env['CNT'][0] = env['CNT'][0] + 1
s = str(tgts) expect = str([test.workpath('2.out'), test.workpath('3.out')]) assert s == expect, s
s = map(str, tgts) expect = [test.workpath('2.out'), test.workpath('3.out')] expect = map(os.path.normcase, expect) assert map(os.path.normcase, s) == expect, s
def func(target, source, env): open(str(target[0]), "w") if (len(source) == 1 and len(target) == 1): env['CNT'][0] = env['CNT'][0] + 1
if SCons.Util.is_List(d) or isinstance(d, tuple):
if d is None: continue elif SCons.Util.is_List(d) or isinstance(d, tuple):
def processDefines(defs): """process defines, resolving strings, lists, dictionaries, into a list of strings """ if SCons.Util.is_List(defs): l = [] for d in defs: if SCons.Util.is_List(d) or isinstance(d, tuple): if len(d) >= 2: l.append(str(d[0]) + '=' + str(d[1])) else: l.append(str(d[0])) elif SCons.Util.is_Dict(d)...
raise
raise SCons.Errors.UserError("DEFINE %s is not a list, dict, string or None."%repr(d))
def processDefines(defs): """process defines, resolving strings, lists, dictionaries, into a list of strings """ if SCons.Util.is_List(defs): l = [] for d in defs: if SCons.Util.is_List(d) or isinstance(d, tuple): if len(d) >= 2: l.append(str(d[0]) + '=' + str(d[1])) else: l.append(str(d[0])) elif SCons.Util.is_Dict(d)...
env.Clean(aFile_base + '.aux',target[0])
env.Clean(target[0],aFile_base + '.aux')
def tex_emitter_core(target, source, env, graphics_extensions): """An emitter for TeX and LaTeX sources. For LaTeX sources we try and find the common created files that are needed on subsequent runs of latex to finish tables of contents, bibliographies, indices, lists of figures, and hyperlink references. """ basename ...
super(io.StringIO, self).write(unicode(s))
super(_StringIO, self).write(unicode(s))
def write(self, s): super(io.StringIO, self).write(unicode(s))
sys.stdout = StringIOClass()
sys.stdout = StringIO()
def write(self, s): super(io.StringIO, self).write(unicode(s))
return sorted(uniquify(versions))
def keyfunc(str): """Given a dot-separated version string, return a tuple of ints representing it.""" return [int(x) for x in str.split('.')] return sorted(uniquify(versions), key=keyfunc, reverse=True)
def get_all_compiler_versions(): """Returns a sorted list of strings, like "70" or "80" or "9.0" with most recent compiler version first. """ versions=[] if is_windows: if is_win64: keyname = 'Software\\WoW6432Node\\Intel\\Compilers\\C++' else: keyname = 'Software\\Intel\\Compilers\\C++' try: k = SCons.Util.RegOpenKeyE...
if out not in (sys.stdout, None):
if close_out:
def do_revisions(cr, opts, branch, revisions, scripts): """ Time the SCons branch specified scripts through a list of revisions. We assume we're in a (temporary) directory in which we can check out the source for the specified revisions. """ stdout = sys.stdout stderr = sys.stderr status = 0 if opts.logsdir and not ...
t = msvc_version.split(".")
msvc_ver_numeric = string.join(filter(lambda x: x in string.digits + ".", msvc_version), '') t = msvc_version_numeric.split(".")
def msvc_version_to_maj_min(msvc_version): t = msvc_version.split(".") if not len(t) == 2: raise ValueError("Unrecognized version %s" % msvc_version) try: maj = int(t[0]) min = int(t[1]) return maj, min except ValueError, e: raise ValueError("Unrecognized version %s" % msvc_version)
d[types.InstanceType] = _semi_deepcopy_inst
d[InstanceType] = _semi_deepcopy_inst
def _semi_deepcopy_inst(x): if hasattr(x, '__semi_deepcopy__'): return x.__semi_deepcopy__() elif isinstance(x, UserDict): return x.__class__(_semi_deepcopy_dict(x)) elif isinstance(x, UserList): return x.__class__(_semi_deepcopy_list(x)) else: return x
if hasattr(obj, '__class__') and obj.__class__ != types.TypeType:
if hasattr(obj, '__class__') and obj.__class__ is not type:
def f(self, x, y): self.z = x + y
def f_local(target, source, env, for_signature):
def f_local(target, source, env, for_signature, LocalFunc=LocalFunc):
def f_local(target, source, env, for_signature): return SCons.Action.Action(LocalFunc)
def f_local(target, source, env, for_signature):
def f_local(target, source, env, for_signature, LocalFunc=LocalFunc):
def f_local(target, source, env, for_signature): return SCons.Action.Action(LocalFunc, varlist=['XYZ'])
search = [os.path.dirname(sys.argv[0])] if search[0] == '': search[0] = '.'
search = [script_dir]
def must_copy(dst, src): if not os.path.exists(dst): return 1 return open(dst, 'rb').read() != open(src, 'rb').read()
if hasattr(x, '__semi_deepcopy__'):
if hasattr(x, '__semi_deepcopy__') and callable(x.__semi_deepcopy__):
def semi_deepcopy(x): copier = _semi_deepcopy_dispatch.get(type(x)) if copier: return copier(x) else: if hasattr(x, '__semi_deepcopy__'): return x.__semi_deepcopy__() elif isinstance(x, UserDict): return x.__class__(_semi_deepcopy_dict(x)) elif isinstance(x, UserList): return x.__class__(_semi_deepcopy_list(x)) return...
if self.remove_this(fname, fpath): result.remove(fname) elif self.search_this(fpath): body = open(path, 'r').read()
if self.search_this(fpath) and not self.remove_this(fname, fpath): body = open(fpath, 'r').read()
def find_missing(self): result = [] for dirpath, dirnames, filenames in os.walk(self.directory): for fname in filenames: fpath = os.path.join(dirpath, fname) if self.remove_this(fname, fpath): result.remove(fname) elif self.search_this(fpath): body = open(path, 'r').read() for expr in self.expressions: if not expr.sear...
msg = '%s: missing %s' % (path, repr(expr.pattern))
msg = '%s: missing %s' % (fpath, repr(expr.pattern))
def find_missing(self): result = [] for dirpath, dirnames, filenames in os.walk(self.directory): for fname in filenames: fpath = os.path.join(dirpath, fname) if self.remove_this(fname, fpath): result.remove(fname) elif self.search_this(fpath): body = open(path, 'r').read() for expr in self.expressions: if not expr.sear...
os.execve(sys.executable, args, os.environ)
sys.exit(subprocess.Popen(args, env=os.environ).wait())
def find(file, search=search): for dir in search: f = os.path.join(dir, file) if os.path.exists(f): return os.path.normpath(f) sys.stderr.write("could not find `%s' in search path:\n" % file) sys.stderr.write("\t" + "\n\t".join(search) + "\n") sys.exit(2)
debug("sdk.py: get_sdk_vc_script():arch_string:%s host_arch:%s target_arch:%s"%(arch_string, host_arch, target_arch))
def get_sdk_vc_script(self,host_arch, target_arch): """ Return the script to initialize the VC compiler installed by SDK """ arch_string=target_arch if (host_arch != target_arch): arch_string='%s_%s'%(host_arch,target_arch) #print "arch_string:%s host_arch:%s target_arch:%s"%(arch_string, # ...
debug("sdk.py: get_sdk_vc_script():file:%s"%file)
def get_sdk_vc_script(self,host_arch, target_arch): """ Return the script to initialize the VC compiler installed by SDK """ arch_string=target_arch if (host_arch != target_arch): arch_string='%s_%s'%(host_arch,target_arch) #print "arch_string:%s host_arch:%s target_arch:%s"%(arch_string, # ...
debug('trying to find SDK %s' % sdk.version)
debug('MSCommon/sdk.py: trying to find SDK %s' % sdk.version)
def get_installed_sdks(): global InstalledSDKList global InstalledSDKMap if InstalledSDKList is None: InstalledSDKList = [] InstalledSDKMap = {} for sdk in SupportedSDKList: debug('trying to find SDK %s' % sdk.version) if sdk.get_sdk_dir(): debug('found SDK %s' % sdk.version) InstalledSDKList.append(sdk) InstalledSDKMa...
debug('found SDK %s' % sdk.version)
debug('MSCommon/sdk.py:found SDK %s' % sdk.version)
def get_installed_sdks(): global InstalledSDKList global InstalledSDKMap if InstalledSDKList is None: InstalledSDKList = [] InstalledSDKMap = {} for sdk in SupportedSDKList: debug('trying to find SDK %s' % sdk.version) if sdk.get_sdk_dir(): debug('found SDK %s' % sdk.version) InstalledSDKList.append(sdk) InstalledSDKMa...
def __call__(self, target, source, env, *args, **kw): args = (self, target, source, env) + args c = self.get_parent_class(env) return c.__call__(*args, **kw)
def __call__(self, *args, **kw): c = self.get_parent_class(args[2]) return c.__call__(self, *args, **kw)
def __call__(self, target, source, env, *args, **kw): args = (self, target, source, env) + args c = self.get_parent_class(env) #TODO(1.5) return c.__call__(*args, **kw) return c.__call__(*args, **kw)
0 0.00[012] 1 0.00[012]
0 \d.\d\d\d 1 \d.\d\d\d
def _main(): pass
msvc_ver_numeric = string.join(filter(lambda x: x in string.digits + ".", msvc_version), '') t = msvc_version_numeric.split(".")
t = msvc_version.split(".")
def msvc_version_to_maj_min(msvc_version): msvc_ver_numeric = string.join(filter(lambda x: x in string.digits + ".", msvc_version), '') t = msvc_version_numeric.split(".") if not len(t) == 2: raise ValueError("Unrecognized version %s" % msvc_version) try: maj = int(t[0]) min = int(t[1]) return maj, min except ValueEr...
_is_win64 = has_reg(r"Software\Wow6432Node")
_is_win64 = False if os.environ.get('PROCESSOR_ARCHITECTURE','x86') != 'x86': _is_win64 = True if os.environ.get('PROCESSOR_ARCHITEW6432'): _is_win64 = True if os.environ.get('ProgramW6432'): _is_win64 = True
def is_win64(): """Return true if running on windows 64 bits. Works whether python itself runs in 64 bits or 32 bits.""" # Unfortunately, python does not provide a useful way to determine # if the underlying Windows OS is 32-bit or 64-bit. Worse, whether # the Python itself is 32-bit or 64-bit affects what it returns...
scons: \\*\\*\\* .* is not a Builder\\.
scons: *** 1 is not a Builder.
def mkdir(env, target, source): return None
status=2, match=TestSCons.match_re)
status=2)
def mkdir(env, target, source): return None
p = SCons.Util.Proxy(f1)
class MyProxy(SCons.Util.Proxy): __str__ = SCons.Util.Delegate('__str__') p = MyProxy(f1)
def test_proxy(self): """Test a Node.FS object wrapped in a proxy instance""" f1 = self.fs.File('fff') p = SCons.Util.Proxy(f1) f2 = self.fs.Entry(p) assert f1 is f2, (f1, f2)
assert f1 is f2, (f1, f2)
assert f1 is f2, (f1, str(f1), f2, str(f2))
def test_proxy(self): """Test a Node.FS object wrapped in a proxy instance""" f1 = self.fs.File('fff') p = SCons.Util.Proxy(f1) f2 = self.fs.Entry(p) assert f1 is f2, (f1, f2)
SConstruct_file_line = test.python_file_line(test.workpath('SConstruct'), 17)[:-1]
SConstruct_file_line = test.python_file_line(test.workpath('SConstruct'), 16)[:-1]
def cat(env, source, target): target = str(target[0]) f = open(target, "wb") for src in source: f.write(open(str(src), "rb").read()) f.close()
setattr(obj, name, types.MethodType(function, obj, cls))
setattr(obj, name, types.MethodType(function, obj, obj.__class__))
def f(self, x, y): self.z = x + y
global TimeStamp
global TimeStampDefault
def Trace(msg, file=None, mode='w', tstamp=None): """Write a trace message to a file. Whenever a file is specified, it becomes the default for the next call to Trace().""" global TraceDefault global TimeStamp global PreviousTime if file is None: file = TraceDefault else: TraceDefault = file if tstamp is None: tstamp =...
return string.replace(str(self._Proxy__subject), os.sep, Sep)
return str(self._Proxy__subject).replace(os.sep, Sep)
def __str__(self): return string.replace(str(self._Proxy__subject), os.sep, Sep)
return map(lambda x: string.replace(str(x), os.sep, Sep), orig_RDirs(self, pathlist))
return [str(x).replace(os.sep, Sep) for x in orig_RDirs(self, pathlist)]
def my_RDirs(self, pathlist, orig_RDirs=orig_RDirs): return map(lambda x: string.replace(str(x), os.sep, Sep), orig_RDirs(self, pathlist))
result.append(string.join(map(str, cmd))) return string.join(result, '\\n')
result.append(' '.join(map(str, cmd))) return '\\n'.join(result)
def Str(target, source, env, cmd=""): result = [] for cmd in env.subst_list(cmd, target=target, source=source): result.append(string.join(map(str, cmd))) return string.join(result, '\\n')
filter_tools = string.split('%(tools)s')
filter_tools = '%(tools)s'.split()
def JarCom(target, source, env): target = str(target[0]) class_files = [] for src in map(str, source): os.path.walk(src, find_class_files, class_files) f = open(target, "wb") for cf in class_files: f.write(open(cf, "rb").read()) f.close()
output = f.data[:i+1].replace('__ROOT__', '') output = output.replace('<', '&lt;') output = output.replace('>', '&gt;')
output = self.for_display(f.data[:i+1])
def end_scons_example(self): e = self.e files = [f for f in e.files if f.printme] if files: self.outfp.write('<programlisting>') for f in files: if f.printme: i = len(f.data) - 1 while f.data[i] == ' ': i = i - 1 output = f.data[:i+1].replace('__ROOT__', '') output = output.replace('<', '&lt;') output = output.replace(...
content = content.replace('<', '&lt;') content = content.replace('>', '&gt;')
content = self.for_display(content)
def end_scons_output(self): # The real raison d'etre for this script, this is where we # actually execute SCons to fetch the output. o = self.o e = o.e t = TestCmd.TestCmd(workdir='', combine=1) if o.preserve: t.preserve() t.subdir('ROOT', 'WORK') t.rootpath = t.workpath('ROOT').replace('\\', '\\\\')
output = f.data.replace('__ROOT__', '')
output = self.for_display(f.data)
def end_sconstruct(self): f = self.f self.outfp.write('<programlisting>') output = f.data.replace('__ROOT__', '') self.outfp.write(output + '</programlisting>') delattr(self, 'f') self.afunclist = self.afunclist[:-1]
for c in ['.', '[', ']', '(', ')', '*', '+', '?']:
for c in '.[]()*+?\\':
def re_escape(str): for c in ['.', '[', ']', '(', ')', '*', '+', '?']: # Not an exhaustive list. str = str.replace(c, '\\' + c) return str
cmd = ['gcc', '-v']
cmd = 'gcc -v'
def gccFortranLibs(): """Test which gcc Fortran startup libraries are required. This should probably move into SCons itself, but is kind of hacky. """ libs = ['g2c'] cmd = ['gcc', '-v'] try: import subprocess except ImportError: try: import popen2 stderr = popen2.popen3(cmd)[2].read() except OSError: return libs else...
stderr = subprocess.Popen(cmd, stderr=subprocess.PIPE).communicate()[1]
p = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE) stderr = p.stderr.read()
def gccFortranLibs(): """Test which gcc Fortran startup libraries are required. This should probably move into SCons itself, but is kind of hacky. """ libs = ['g2c'] cmd = ['gcc', '-v'] try: import subprocess except ImportError: try: import popen2 stderr = popen2.popen3(cmd)[2].read() except OSError: return libs else...
t = msvc_version.split(".") if not len(t) == 2: raise ValueError("Unrecognized version %s" % msvc_version) try: maj = int(t[0]) min = int(t[1]) return maj, min except ValueError, e: raise ValueError("Unrecognized version %s" % msvc_version)
msvc_ver_numeric = string.join(filter(lambda x: x in string.digits + ".", msvc_version), '') t = msvc_version_numeric.split(".") if not len(t) == 2: raise ValueError("Unrecognized version %s" % msvc_version) try: maj = int(t[0]) min = int(t[1]) return maj, min except ValueError, e: raise ValueError("Unrecognized versi...
def msvc_version_to_maj_min(msvc_version): t = msvc_version.split(".") if not len(t) == 2: raise ValueError("Unrecognized version %s" % msvc_version) try: maj = int(t[0]) min = int(t[1]) return maj, min except ValueError, e: raise ValueError("Unrecognized version %s" % msvc_version)
def __call__(self, *args, **kw): c = self.get_parent_class(args[2]) return c.__call__(self, *args, **kw)
def __call__(self, target, source, env, *args, **kw): c = self.get_parent_class(env) return c.__call__(self, target, source, env, *args, **kw)
def __call__(self, *args, **kw): c = self.get_parent_class(args[2]) # args[2] is env return c.__call__(self, *args, **kw)
else:
elif not vc_script and not sdk_script:
def msvc_setup_env(env): debug('msvc_setup_env()') version = get_default_version(env) if version is None: warn_msg = "No version of Visual Studio compiler found - C/C++ " \ "compilers most likely not set correctly" SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, warn_msg) return None debug('msvc_setup_env: u...
host = _ARCH_TO_CANONICAL[host_platform]
host = _ARCH_TO_CANONICAL[host_platform.lower()]
def get_host_target(env): debug('vc.py:get_host_target()') host_platform = env.get('HOST_ARCH') if not host_platform: host_platform = platform.machine() # TODO(2.5): the native Python platform.machine() function returns # '' on all Python versions before 2.6, after which it also uses # PROCESSOR_ARCHITECTURE. if not ...
target = _ARCH_TO_CANONICAL[target_platform]
target = _ARCH_TO_CANONICAL[target_platform.lower()]
def get_host_target(env): debug('vc.py:get_host_target()') host_platform = env.get('HOST_ARCH') if not host_platform: host_platform = platform.machine() # TODO(2.5): the native Python platform.machine() function returns # '' on all Python versions before 2.6, after which it also uses # PROCESSOR_ARCHITECTURE. if not ...
print "Key: %s, Value: %s, pre: %s, trans: %s" % ( key, value, pre, self.translate( pre, l10n ) )
def templatize( self, file, type, locale, l10n=None ): with codecs.open( file, 'rU', 'utf-8' ) as f: src = f.read() newsrc = [] blocks = re.split( r'{% blocktrans (?:with "((?:\\"|[^"])*)" as (\w+) )?%}|<blocktrans>|<!-- blocktrans -->|/\* blocktrans \*/', src )
line += " " line += "%.2f%%" % (percentage * 100)
line += "-" line += "] %.2f%%" % (percentage * 100)
def bar(percentage): length = 25 bar_length = length * percentage
lines.append(Context.Line("`%4d:%6d " % (score, count) + bar(percentage), color=Color.BLUE, face=Face.MONOSPACE))
lines.append(Context.Line("`%4d:%6d " % (score, count) + bar(percentage), Color.BLUE, Face.MONOSPACE))
def bar(percentage): length = 33 bar_length = int(length * percentage)
lines.append(Formatter.Line("%s%3d:%s%3d " % (header, score, gen_indent(1), count) + bar(percentage), color=Color.BLUE, font=Font.MONOSPACE))
lines.append(Formatter.Line("`%s%3d:%s%3d " % (header, score, gen_indent(1), count) + bar(percentage), color=Color.BLUE, font=Font.MONOSPACE))
def bar(percentage): length = 33 bar_length = int(length * percentage)
self.add_line("Left Team: MaxWinRate %.2f%%, MinWinRate %.2f%%" % (self.max_win_rate * 100, self.min_win_rate * 100), Color.GRAY)
if self.left_count > 0: self.add_line("Left Team: MaxWinRate %.2f%%, MinWinRate %.2f%%" % (self.max_win_rate * 100, self.min_win_rate * 100), Color.GRAY)
def do_some_formatting(self): self.add_line(self.title, color=Color.BLUE) self.add_newline()
total_game.dump(" ")
total_game.dump(header)
def dump(self, header): game_count = float(self.count)
print "Only Valid Game" valid_game.dump(" ")
if header: print "Only Valid Game:" valid_game.dump(header)
def dump(self, header): game_count = float(self.count)