User:WindBOT/CoreSource: Difference between revisions

Jump to navigation Jump to search
m
backport changes from tf wiki
m (Backported changes from tf wiki windbot)
m (backport changes from tf wiki)
Line 26: Line 26:
import subprocess
import subprocess
import cStringIO as StringIO
import cStringIO as StringIO
import shutil
import wikitools
import wikitools
import wikiUpload
import wikiUpload
Line 101: Line 102:
t.join()
t.join()
self.tasks = self.tasks[numThreads:]
self.tasks = self.tasks[numThreads:]
def getTempFilename():
def getTempFilename(extension=None):
global config
global config
f = tempfile.mkstemp(prefix=config['tempPrefix'])
if extension is None:
f = tempfile.mkstemp(prefix=config['tempPrefix'])
else:
f = tempfile.mkstemp(suffix=u'.' + u(extension), prefix=config['tempPrefix'])
os.close(f[0]) # Damn you Python I just want a filename
os.close(f[0]) # Damn you Python I just want a filename
return f[1]
return u(f[1])


def wiki():
def wiki():
Line 1,116: Line 1,120:
languages[u(key)][curlang] = u(value)
languages[u(key)][curlang] = u(value)
else:
else:
pass #print 'Invalid line:', l.__repr__()
pass
return languages
return languages
def languagesFilter(languages, commonto=None, prefix=None, suffix=None, exceptions=[]):
def languagesFilter(languages, commonto=None, prefix=None, suffix=None, exceptions=[]):
Line 1,158: Line 1,162:
else:
else:
addSafeFilter(f, language=targetPageLang)
addSafeFilter(f, language=targetPageLang)
def getRandBits():
return random.getrandbits(128)
def getFileHash(filename):
h = hashlib.md5()
f = open(filename, 'rb')
for i in f.readlines():
h.update(i)
f.close()
return u(h.hexdigest())
def deleteFile(*fs):
for f in fs:
try:
os.remove(tempFile)
except:
pass
def programExists(programName):
try:
result = subprocess.call(['which', programName])
return result == 0
except:
return False
def run():
def run():
global config
global config
Line 1,172: Line 1,197:
updateEditCount()
updateEditCount()
runScheduledTasks()
runScheduledTasks()
import rcNotify
try:
rcNotify.main(once=True)
import rcNotify
rcNotify.main(once=True)
except:
pass
try:
try:
subprocess.Popen(['killall', 'cpulimit']).communicate()
subprocess.Popen(['killall', 'cpulimit']).communicate()

Navigation menu