rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
set.exrule(self._parse_rfc_rrule(value, dtstart=dtstart)) | set.exrule(self._parse_rfc_rrule(value, dtstart=dtstart, ignoretz=ignoretz, tzinfos=tzinfos)) | def _parse_rfc(self, s, dtstart=None, cache=False, unfold=False, forceset=False, compatible=False, ignoretz=False): global parser if compatible: forceset = True s = s.upper() lines = s.splitlines() if not lines: raise ValueError, "empty string" if unfold: i = 0 while i < len(lines): line = lines[i].rstrip() if not line... |
cache=cache) | cache=cache, ignoretz=ignoretz, tzinfos=tzinfos) | def _parse_rfc(self, s, dtstart=None, cache=False, unfold=False, forceset=False, compatible=False, ignoretz=False): global parser if compatible: forceset = True s = s.upper() lines = s.splitlines() if not lines: raise ValueError, "empty string" if unfold: i = 0 while i < len(lines): line = lines[i].rstrip() if not line... |
ips = json.loads(subprocess.check_output(['grep', "\"addrs\":", os.path.join(app.config['CACHE_ROOT'],'tunslip6.log')]).replace(',]',']')) | addrstr = None while addrstr == None: try: addrstr = subprocess.check_output(['grep', "\"addrs\":", os.path.join(app.config['CACHE_ROOT'],'tunslip6.log')]).replace(',]',']') except subprocess.CalledProcessError: print "couldn't find radio ip addr: retrying..." time.sleep(1) ips = json.loads(addrstr) | def get_radio_ip(): # it's diffcult to get the trailing commas correct in the Contiki IP addr output # so we don't (get it correct) and fix up the last trailing comma here ips = json.loads(subprocess.check_output(['grep', "\"addrs\":", os.path.join(app.config['CACHE_ROOT'],'tunslip6.log')]).replace(',]',']')) return ip... |
time.sleep(1) radio['ips'] = get_radio_ip()['addrs'] print "Radio ips are %s" % (radio['ips']) | def load_radio(): subprocess.call(['killall', 'tunslip6']) radio = json.loads(db.get('conf/radio')) tunslip = json.loads(db.get('conf/tunslip')) try: subprocess.call(['systemctl', 'stop', 'serial-getty@ttyS0.service']) except OSError: print "error disabling serial-getty ttyS0" try: subprocess.call(['uartsel', 'mc']) ... | |
while fails < 3: | while fails < 3 and addrstr == None: | def grep_radio_ip(): # it's diffcult to get the trailing commas correct in the Contiki IP addr output # so we don't (get it correct) and fix up the last trailing comma here addrstr = None fails = 0 while fails < 3: try: addrstr = subprocess.check_output(['grep', "\"addrs\":", os.path.join(app.config['CACHE_ROOT'],'tun... |
</fontconfig>''' % fc_cache) | </fontconfig>''' % (appdir + '/Contents/Resources/share/fonts/', fc_cache)) | def check_fontconfig (appdir): prefix = appdir + '/Contents/Resources' my_sysfont_dir = prefix + '/share/SystemFonts' sysfont_dir = '/System/Library/Fonts' fc_cache = (prefix + '/font.cache-1') local_fc_conf = open (prefix + '/etc/fonts/local.conf','w') local_fc_conf.write ('''<?xml version="1.0"?> |
self.request.serverVariables["SCRIPT_NAME"] += '/{%s}' % oSession.sessionid self.request.serverVariables["AUTH_USER"] = oSession.user.displayName | if not oSession.sessionid in self.request.serverVariables["SCRIPT_NAME"]: self.request.serverVariables["SCRIPT_NAME"] += '/{%s}' % oSession.sessionid else: lstScript = self.request.serverVariables["SCRIPT_NAME"].split('/') self.request.serverVariables["SCRIPT_NAME"] = "/%s/{%s}" %(lstScript[1], oSession.sessionid) sel... | def getResponse(self): # get request parameters sMethod = self.request.serverVariables['REQUEST_METHOD'] sBrowser = self.request.serverVariables['HTTP_USER_AGENT'] sLang = self.request.getLang() sPath = self.request.serverVariables.setdefault('PATH_INFO', '/') self.response = response.BaseResponse() |
self._activeTxns -= aborted | from porcupine.db import db as dbhandle dbhandle._activeTxns -= aborted | def maintain(self): while self.running: time.sleep(1.0) # checkpoint self._env.txn_checkpoint(0, self.checkpoint_interval, 0) # deadlock detection try: aborted = self._env.lock_detect(db.DB_LOCK_RANDOM, db.DB_LOCK_CONFLICT) if aborted: self._activeTxns -= aborted logger.critical("Deadlock: Aborted %d deadlocked transac... |
print 'INFO: uninstalling published directory "%s"' % app_name | print 'INFO: uninstalling published directory "%s"' % dir_name | def uninstall(self): print 'INFO: uninstalling [%s-%s] package...' % (self.name, self.version) # registrations conf_file = configfiles.ConfigFileManager('conf/store.xml') pkgnode = conf_file.getPackageNode(self.name) if pkgnode: print 'INFO: removing package registrations' conf_file.removePackageNode(pkgnode) conf_fil... |
print 'INFO: adding published directory "%s"' % appname | print 'INFO: adding published directory "%s"' % dirname | def create(self): # registrations conf_file = configfiles.ConfigFileManager('conf/store.xml') pkgnode = conf_file.getPackageNode(self.name) if pkgnode: print 'INFO: extracting package registrations' regsFile = file(serverSettings.temp_folder + '/_regs.xml', 'w') regsFile.write('<config>\n' + pkgnode.toxml('utf-8') + '\... |
Makefile = Makefile + "rebuild:\tclean build\n\n" | def write_makefile(self, doc, dir): """ Writes a Makefile to convert the source files into DocBook XML. """ | |
rebuildmake = rebuildmake + "\tcd " + str(docid) + "; $(MAKE) rebuild 2>>make.log\n" | def write_main_makefile(self): docsmake = '' docbookmake = '' xmlmake = '' htmlmake = '' indexmake = '' txtmake = '' omfmake = '' cleanmake = '' rebuildmake = '' makeneeded = 0 for docid in lampadas.docs.keys(): doc = lampadas.docs[docid] if doc.errors.count()==0 and doc.files.error_count()==0: for file in doc.files.ke... | |
Makefile = Makefile + "rebuild:\n" + rebuildmake + "\n\n" | def write_main_makefile(self): docsmake = '' docbookmake = '' xmlmake = '' htmlmake = '' indexmake = '' txtmake = '' omfmake = '' cleanmake = '' rebuildmake = '' makeneeded = 0 for docid in lampadas.docs.keys(): doc = lampadas.docs[docid] if doc.errors.count()==0 and doc.files.error_count()==0: for file in doc.files.ke... | |
self.targets.add(dbsgmlfile, [sourcefile.file_only], [Command('wt2db -n -s ' + dbsgmlfile + ' -o ' + sourcefile.file_only, output_to='log/wt2db.log')]) | self.targets.add(dbsgmlfile, [sourcefile.file_only], [Command('wt2db -n -s ' + sourcefile.file_only + ' -o ' + dbsgmlfile, output_to='log/wt2db.log', stderr_check=1)]) | def __init__(self, doc_id): self.doc_id = int(doc_id) self.doc = lampadas.docs[self.doc_id] self.workdir = config.cache_dir + str(self.doc_id) + '/work/' self.filename = '' self.targets = Targets() # If the file is not to be published (Archived or Normal status), # or if it has not been mirrored successfully, skip it... |
self.targets.add(dbsgmlfile, [sourcefile.file_only], [Command('wt2db -n -s ' + dbsgmlfile + ' -o ' + sourcefile.file_only, errors_to='wt2db.log', stderr_check=1)]) | self.targets.add(dbsgmlfile, [sourcefile.file_only], [Command('wt2db -n -s ' + sourcefile.file_only + ' -o ' + dbsgmlfile, output_to='log/wt2db.log', stderr_check=1)]) | def __init__(self, doc_id): self.doc_id = int(doc_id) self.doc = lampadas.docs[self.doc_id] self.workdir = config.cache_dir + str(self.doc_id) + '/work/' self.filename = '' self.targets = Targets() # If the file is not to be published (Archived or Normal status), # or if it has not been mirrored successfully, skip it... |
box = '<table class="box"><tr>\n' | box = '<table class="box" width="100%"><tr>\n' | def letters(self, uri): log(3, 'Creating letter table') box = '<table class="box"><tr>\n' for letter in string.uppercase: if letter==uri.letter: box = box + '<th>' + letter + '</th>\n' else: box = box + '<th><a href="/' + uri.filename + '/' + letter + '|uri.lang_ext|">' + letter + '</a></th>\n' box = box + '</tr></tabl... |
box = '<table class="box"><tr><th colspan=2>|strusers|</th></tr>\n' | box = '<table class="box" width="100%"><tr><th colspan=2>|strusers|</th></tr>\n' | def users(self, uri, build_user): log(3, 'Creating users table') box = '<table class="box"><tr><th colspan=2>|strusers|</th></tr>\n' box = box + '<tr>\n' box = box + '<th class="collabel">|strusername|</th>\n' box = box + '<th class="collabel">|strname|</th>\n' box = box + '</tr>\n'; if uri.letter > '': usernames = lam... |
box = '<table class="navbox"><tr><th>' + section.name[uri.lang] + '</th></tr>\n' | box = '<table class="navbox" width="210"><tr><th>' + section.name[uri.lang] + '</th></tr>\n' | def section_menu(self, uri, user, section_code): log(3, "Creating section menu: " + section_code) section = lampadasweb.sections[section_code] box = '<table class="navbox"><tr><th>' + section.name[uri.lang] + '</th></tr>\n' box = box + '<tr><td>' keys = lampadasweb.pages.sort_by('sort_order') for key in keys: page = la... |
box = WOStringIO('''<table class="navbox"> | box = WOStringIO('''<table class="navbox" width="210"> | def topics(self, uri): log(3, 'Creating topics menu') box = WOStringIO('''<table class="navbox"> <tr><th>|strtopics|</th></tr> <tr><td><ol>''') keys = lampadas.topics.sort_by('num') for key in keys: topic = lampadas.topics[key] box.write('<li><a href="/topic/%s|uri.lang_ext|">%s</a></li>\n' % (topic.code, topic.name[ur... |
box = WOStringIO('''<table class="navbox"> | box = WOStringIO('''<table class="navbox" width="210"> | def types(self, uri): log(3, 'Creating types menu') box = WOStringIO('''<table class="navbox"> <tr><th>|strtypes|</th></tr> <tr><td>''') keys = lampadas.types.sort_by('sort_order') for key in keys: type = lampadas.types[key] box.write('<a href="/type/%s|uri.lang_ext|">%s</a><br>\n' % (type.code, type.name[uri.lang])) b... |
box = '''<table class="navbox"> | box = '''<table class="navbox" width="210"> | def login(self, uri, user): if self.command_line==1: return '' if user: log(3, 'Creating active user box') box = '''<table class="navbox"> <tr><th>|stractive_user|</th></tr> <form name="logout" action="/data/session/logout"> <input name="username" type="hidden" value="%s"> <tr><td align="center"> <a href="/user/|sessio... |
<a href="/mailpass">|strmail_passwd||uri.lang_ext|</a><br> | <a href="/mailpass|uri.lang_ext|">|strmail_passwd|</a><br> | def login(self, uri, user): if self.command_line==1: return '' if user: log(3, 'Creating active user box') box = '''<table class="navbox"> <tr><th>|stractive_user|</th></tr> <form name="logout" action="/data/session/logout"> <input name="username" type="hidden" value="%s"> <tr><td align="center"> <a href="/user/|sessio... |
box = WOStringIO('''<table class="navbox"> | box = WOStringIO('''<table class="navbox" width="210"> | def navsessions(self, uri, user): if user and user.admin > 0: log(3, 'Creating navsessions table') box = WOStringIO('''<table class="navbox"> <tr><th>|strsessions|</th></tr> <tr><td> ''') keys = sessions.sort_by('username') for key in keys: session = sessions[key] box.write('<a href="/user/%s|uri.lang_ext|">%s</a><br>\... |
box = WOStringIO('''<table class="box"> | box = WOStringIO('''<table class="box" width="100%"> | def tabsessions(self, uri, user): if user and user.admin > 0: log(3, 'Creating sessions table') box = WOStringIO('''<table class="box"> <tr><th colspan="4">|strsessions|</th></tr> <tr> <th class="collabel">|strusername|</th> <th class="collabel">|strip_address|</th> <th class="collabel">|strurl|</th> <th class="collabe... |
box = WOStringIO('''<table class="navbox"> | box = WOStringIO('''<table class="navbox" width="210"> | def languages(self, uri): log(3, 'Creating languages table') box = WOStringIO('''<table class="navbox"> <tr><th>|strlanguages|</th></tr> <tr><td> ''') keys = lampadas.languages.sort_by_lang('name', uri.lang) for key in keys: language = lampadas.languages[key] if language.supported > 0: if uri.data > '': add_data = '/' ... |
box.write('<a href="/%s%s.%s">%s</a><br>\n' | box.write('<a href="/%s%s.%s.html">%s</a><br>\n' | def languages(self, uri): log(3, 'Creating languages table') box = WOStringIO('''<table class="navbox"> <tr><th>|strlanguages|</th></tr> <tr><td> ''') keys = lampadas.languages.sort_by_lang('name', uri.lang) for key in keys: language = lampadas.languages[key] if language.supported > 0: if uri.data > '': add_data = '/' ... |
<table class="box"> | <table class="box" width="100%"> | def tabmailpass(self, uri): log(3, 'Creating mailpass table') box = '''<form name="mailpass" action="/data/save/mailpass"> <table class="box"> <tr><th colspan="2">|strmail_passwd|</th></tr> <tr> <td><input type="text" name="email"></td> <td align="center"><input type="submit" name="mailpass" value="|strmail_passwd|"></... |
self.doc.last_updated, | self.doc.last_update, | def __init__(self, doc_id): self.id = doc_id self.doc = lampadas.docs[doc_id] omf = WOStringIO('<resource id="%s">\n' '%s' '%s' '%s' '<title>%s</title>\n' '<date>%s</date>\n' '<versiongroup>\n' ' <version>\n' ' <id>%s</id>\n' ' <date>%s</date>\n' ' </version>\n' '</versiongroup>\n' '<type>%s</type>\n' '%s\n' '<... |
def __init__(self,dbname) : """ Init database connection """ self.dbname = None def get_config(self, name) : """ Return value of config parameter """ cur = self.connection.cursor() cur.execute("SELECT value FROM config WHERE name='%s'", (name,)) return cur.fetchone() def mk_user(self, row) : """ User factory """ u... | def __init__(self,dbname) : """ Init database connection """ self.dbname = None def get_config(self, name) : """ Return value of config parameter """ cur = self.connection.cursor() cur.execute("SELECT value FROM config WHERE name='%s'", name) return cur.fetchone() def mk_user(self, row) : """ User factory """ u = ... | def get_database(dbtype, dbname) : """ To let people use different DBs, use specific class derived from Database """ if dbtype == 'pgsql' : return PgSQLDatabase(dbname) elif dbtype == 'mysql' : return MySQLDatabase(dbname) else : raise UnknownDBException('Unknown database type %s' % dbtype) |
} def SaveSubtopic(self, topic_num, subtopic_num, subtopic_name, subtopic_description) : """ $DB->Exec("UPDATE subtopic SET subtopic_name=" . wsq($subtopic_name) . ", subtopic_description=" . wsq($subtopic_description) . " WHERE topic_num=$topic_num AND subtopic_num=$subtopic_num") }""" pass | $DB->Exec("UPDATE subtopic SET subtopic_name=" . wsq($subtopic_name) . ", subtopic_description=" . wsq($subtopic_description) . " WHERE topic_num=$topic_num AND subtopic_num=$subtopic_num") }""" pass | def Subtopics(self, topic_num) : my %subtopics = () my $sql = "SELECT topic.topic_num, topic_name, topic_description, subtopic_num, subtopic_name, subtopic_description from subtopic, topic WHERE subtopic.topic_num = topic.topic_num" $sql .= " AND topic.topic_num = $topic_num" if ($topic_num) my $recordset = $DB->Record... |
pass class User : """ A user is known by the system and can login to manipulate documents and act on the database according to his rights. """ def __ init__(self) : self.username = "" self.user_id = None self.firstname = "" self.surname = "" self.name = "%s %s" % (self.firstname, self.surname) self.email = "" self.... | pass | def __init__(self,dbname) : from pyMySQL import MySQL self.cnx = MySQL.connection(dbname=dbname) |
elif user.can_edit(doc_id=doc.doc_id)==0: | elif user.can_edit(doc_id=doc.id)==0: | def doctable(self, uri, user, type_code=None, subtopic_code=None, username=None, maintained=None, maintainer_wanted=None, pub_status_code=None): log(3, "Creating doctable") box = '<table class="box" width="100%"><tr><th colspan="3">|strtitle|</th></tr>' keys = lampadas.docs.sort_by("title") for key in keys: doc = lampa... |
def splitterm(term, sep): """ Splits the term into 2 pieces according to the seperator, and returns them. If the term does not contain the sep, the second string the returned tuple will be ''. """ temp = string.split(term, sep, 1) if len(temp) > 1: return temp[0], temp[1] else: return temp[0], '' | AVAILABLE_LANG = lampadas.languages.keys() | def splitterm(term, sep): """ Splits the term into 2 pieces according to the seperator, and returns them. If the term does not contain the sep, the second string the returned tuple will be ''. """ temp = string.split(term, sep, 1) if len(temp) > 1: return temp[0], temp[1] else: return temp[0], '' |
self.path = "" | self.path = "/" | def __init__(self, uri): |
self.base = uri if self.base[0]=='/': self.base = self.base[1:] | def __init__(self, uri): | |
temp = uri if len(temp)==0: return if temp[0]=='/': temp = temp[1:] | protocol, host, path, params, query, fragment = urlparse.urlparse(uri) self.protocol = protocol if host.find(':') > 0 : self.server, self.port = host.split(':') else : self.server = host self.parameter = query self.anchor = fragment | def __init__(self, uri): |
if len(temp)==0: return if temp[-1]=='/': temp = temp[:-1] | self.base = path path = path.split('/') | def __init__(self, uri): |
if temp.find('://') > 0: self.protocol, temp = splitterm(temp, '://') self.server, temp = splitterm(temp,'/') if self.server.find(':') > 0: self.server, self.port = splitterm(self.server, ':') if temp.find(' temp, self.anchor = splitterm(temp, ' if temp.find('?') > 0: temp, self.parameter = splitterm(temp, '?') temp =... | if not path : return if path[0] == '' : path = path[1:] | def __init__(self, uri): |
if len(temp) > 0: lang = lampadas.languages[temp[0]] if not lang==None: self.lang = temp[0] temp = temp[1:] self.force_lang = 1 self.base = self.base[3:] | if not path : return if path[-1] == '' : path = path[:-1] if not path : return if path[0] in AVAILABLE_LANG : self.force_lang = 1 self.lang, path = path[0], path[1:] self.base = '/'.join(path) | def __init__(self, uri): |
if len(temp) > 0: if temp[0]=='editdoc' or temp[0]=='cvslog': self.filename = temp[0] temp = temp[1:] if len(temp) > 0: self.id = int(temp[0]) elif temp[0]=='topic' or temp[0]=='subtopic' or temp[0]=='type': self.filename = temp[0] temp = temp[1:] if len(temp) > 0: self.code = temp[0] elif temp[0]=='user': self.filenam... | if not path : return if path[0] in ('editdoc','cvslog'): self.filename = path[0] path = path[1:] if path : self.id = int(path[0]) elif path[0] in ('topic','subtopic','type'): self.filename = path[0] path = path[1:] if path : self.code = path[0] elif path[0] in ('user',): self.filename = path[0] path = path[1:] if path ... | def __init__(self, uri): |
if len(temp)==1: self.path = '/' if len(temp[0]) > 0: self.filename = temp[0] else: self.path = string.join(temp[:-1], '/') if len(temp[-1]) > 0: self.filename = temp[-1] | self.path = '/'.join(path[:-1]) if len(path[-1]) > 0: self.filename = path[-1] | def __init__(self, uri): |
print "URI: [" + self.uri + "]" print "Base: [" + self.base + "]" print "Protocol: [" + self.protocol + "]" print "Server: [" + self.server + "]" print "Port: [" + self.port + "]" print "Path: [" + self.path + "]" print "Language: [" + self.lang + "]" print "Forced Language: [" + str(self.force_lang) + "]" print "ID: [... | print "URI: [%s]" % self.uri print "Base: [%s]" % self.base print "Protocol: [%s]" % self.protocol print "Server: [%s]" % self.server print "Port: [%s]" % self.port print "Path: [%s]" % self.path print "Language: [%s]" % self.lang print "Forced Language: [%s]" % self.force_lang print "ID: [%s]" ... | def printdebug(self): print "URI: [" + self.uri + "]" print "Base: [" + self.base + "]" print "Protocol: [" + self.protocol + "]" print "Server: [" + self.server + "]" print "Port: [" + self.port + "]" print "Path: [" + self.path + "]" print "Language: [" + self.lang + "]" print "Forced Language: [" + str(self.force_la... |
docfile = doc.top_file if docfile==None: | topfile = doc.top_file if topfile==None: | def method(self, uri): log(3, 'Creating file_metadata table') if uri.filename > '': sourcefile = dms.sourcefile.get_by_id(uri.filename) elif uri.id > 0: doc = dms.document.get_by_id(uri.id) docfile = doc.top_file if docfile==None: return '' sourcefile = docfile.sourcefile # Read the format_name format = sourcefile.for... |
sourcefile = docfile.sourcefile | def method(self, uri): log(3, 'Creating file_metadata table') if uri.filename > '': sourcefile = dms.sourcefile.get_by_id(uri.filename) elif uri.id > 0: doc = dms.document.get_by_id(uri.id) docfile = doc.top_file if docfile==None: return '' sourcefile = docfile.sourcefile # Read the format_name format = sourcefile.for... | |
format = sourcefile.format | format = topfile.format | def method(self, uri): log(3, 'Creating file_metadata table') if uri.filename > '': sourcefile = dms.sourcefile.get_by_id(uri.filename) elif uri.id > 0: doc = dms.document.get_by_id(uri.id) docfile = doc.top_file if docfile==None: return '' sourcefile = docfile.sourcefile # Read the format_name format = sourcefile.for... |
dtd = sourcefile.dtd | dtd = topfile.dtd | def method(self, uri): log(3, 'Creating file_metadata table') if uri.filename > '': sourcefile = dms.sourcefile.get_by_id(uri.filename) elif uri.id > 0: doc = dms.document.get_by_id(uri.id) docfile = doc.top_file if docfile==None: return '' sourcefile = docfile.sourcefile # Read the format_name format = sourcefile.for... |
% (sourcefile.filename, | % (topfile.filename, | def method(self, uri): log(3, 'Creating file_metadata table') if uri.filename > '': sourcefile = dms.sourcefile.get_by_id(uri.filename) elif uri.id > 0: doc = dms.document.get_by_id(uri.id) docfile = doc.top_file if docfile==None: return '' sourcefile = docfile.sourcefile # Read the format_name format = sourcefile.for... |
sourcefile.dtd_version, sourcefile.title, sourcefile.abstract, sourcefile.version, sourcefile.pub_date, sourcefile.isbn, sourcefile.encoding)) | topfile.dtd_version, topfile.title, topfile.abstract, topfile.version, topfile.pub_date, topfile.isbn, topfile.encoding)) | def method(self, uri): log(3, 'Creating file_metadata table') if uri.filename > '': sourcefile = dms.sourcefile.get_by_id(uri.filename) elif uri.id > 0: doc = dms.document.get_by_id(uri.id) docfile = doc.top_file if docfile==None: return '' sourcefile = docfile.sourcefile # Read the format_name format = sourcefile.for... |
cmd_text = 'cd ' + self.workdir + '; ' + command.command | cmd_text = 'cd ' + self.workdir + '; ' if command.errors_to > '': cmd_text += ' rm -f ' + command.errors_to + '; ' cmd_text = cmd_text + command.command | def make(self, name='all'): """ Runs the makefile specified target (defaulting to all) and records errors, results and other status flags against the document. If the document not been mirrored, this routine will not attempt to build it. |
fh.write(sourcefile.localname + '\n') | fh.write(sourcefile.filename + '\n') | def filereport(self, uri): if not sessions.session: return '|blknopermission|' elif sessions.session.user.can_edit(doc_id=uri.id)==0: return '|blknopermission|' |
if user.username == username: | if user: | def login(req, username, password): user = lampadas.users[username] if user.username == username: if user.password == password: if sessions[username] == None: sessions.add(username) # establish random 20 character session_id. # chars = string.letters + string.digits session_id = '' for x in range(20): session_id += w... |
Makefile = Makefile + "BUILD_HTML = xsltproc --param quiet 1 --maxdepth 100 " + XSLT_PARAMS + ' ' + config.xslt_html + ' ' + xmlfile + ' > ' + htmlfile + " 2>>xsltproc.log\n" Makefile = Makefile + "BUILD_INDEX = xsltproc --param quiet 1 --maxdepth 100 " + XSLT_PARAMS + ' ' + config.xslt_chunk + ' ' + xmlfile + " 2>>xsl... | Makefile = Makefile + "BUILD_HTML = xsltproc --param quiet 1 --maxdepth 100 " + XSLTPROC_PARAMS + ' ' + config.xslt_html + ' ' + xmlfile + ' > ' + htmlfile + " 2>>xsltproc.log\n" Makefile = Makefile + "BUILD_INDEX = xsltproc --param quiet 1 --maxdepth 100 " + XSLTPROC_PARAMS + ' ' + config.xslt_chunk + ' ' + xmlfile + ... | def write_makefile(self, doc, dir): """ Writes a Makefile to convert the source files into DocBook XML. """ |
for key in doc.errors.sort_by('err_id'): | for key in doc.errors.keys('err_id'): | def calc(self): self.reset() |
self['doc_format'].inc(metadata.format_code) self['doc_dtd'].inc(metadata.dtd_code) self['doc_lang'].inc(doc.lang) | self['pub_doc_format'].inc(metadata.format_code) self['pub_doc_dtd'].inc(metadata.dtd_code) self['pub_doc_lang'].inc(doc.lang) | def calc(self): self.reset() |
def user(self, uri, user): | def user(self, uri): | def user(self, uri, user): box = '<table class="box">\n' if uri.username > '': user = lampadas.users[uri.username] box = box + '<form method=GET action="data/save/user" name="user">\n' else: user = User() box = box + '<form method=GET action="data/save/newuser" name="user">\n' box = box + '<input name="username" type=h... |
result = [] | temp, result = [], [] | def sort_by(self, attribute): result = [] for key, item in self.items(): value = getattr(item, attribute) result.append((value, key)) result.sort() for i in xrange(len(result)): result[i] = result[i][1] return result |
result.append((value, key)) result.sort() for i in xrange(len(result)): result[i] = result[i][1] | temp.append((value, key)) temp.sort() for v,k in temp : result.append(k) | def sort_by(self, attribute): result = [] for key, item in self.items(): value = getattr(item, attribute) result.append((value, key)) result.sort() for i in xrange(len(result)): result[i] = result[i][1] return result |
result = [] | temp, result = [], [] | def sort_by_desc(self, attribute): result = [] for key, item in self.items(): value = getattr(item, attribute) result.append((value, key)) result.reverse() for i in xrange(len(result)): result[i] = result[i][1] return result |
result.append((value, key)) result.reverse() for i in xrange(len(result)): result[i] = result[i][1] | temp.append((value, key)) temp.sort() temp.reverse() for v,k in temp : result.append(v) | def sort_by_desc(self, attribute): result = [] for key, item in self.items(): value = getattr(item, attribute) result.append((value, key)) result.reverse() for i in xrange(len(result)): result[i] = result[i][1] return result |
self.targets.add(dbsgmlfile, [sourcefile.file_only], [Command('wt2db -n -s ' + sourcefile.file_only + ' -o ' + dbsgmlfile, output_to='log/wt2db.log', stderr_check=1)]) | self.targets.add(dbsgmlfile, [sourcefile.file_only], [Command('wt2db -n -s ' + sourcefile.file_only + ' -o ' + dbsgmlfile, errors_to='log/wt2db.log', stderr_check=1)]) | def __init__(self, doc_id): self.doc_id = int(doc_id) self.doc = lampadas.docs[self.doc_id] self.workdir = config.cache_dir + str(self.doc_id) + '/work/' self.filename = '' self.targets = Targets() # If the file is not to be published (Archived or Normal status), # or if it has not been mirrored successfully, skip it... |
page = lampadasweb.pages.add(page_code, int(sort_order), section_code, template_code, int(only_dynamic), int(only_registered), int(only_admin), int(only_sysadmin), string.split(data)) | page = lampadasweb.pages.add(page_code, int(sort_order), section_code, template_code, int(only_dynamic), int(only_registered), int(only_admin), int(only_sysadmin), string.split(data, ' ')) | def newpage(req, page_code, sort_order, section_code, template_code, only_dynamic, only_registered, only_admin, only_sysadmin, data): page = lampadasweb.pages.add(page_code, int(sort_order), section_code, template_code, int(only_dynamic), int(only_registered), int(only_admin), int(only_sysadmin), string.split(data)) re... |
page.data = string.split(data) | page.data = string.split(data, ' ') | def page(req, page_code, sort_order, section_code, template_code, only_dynamic, only_registered, only_admin, only_sysadmin, data, adjust_sort_order): page = lampadasweb.pages[page_code] page.sort_order = int(sort_order) page.section_code = section_code page.template_code = template_code page.only_dynamic = int(only_d... |
box = box + '<tr><td><h2>|strcommand|</h2><pre>' + command + '</pre></td></tr>\n' | if sessions.session: if sessions.session.user.admin==1 or sessions.session.user.sysadmin==1: box = box + '<tr><td><h2>|strcommand|</h2><pre>' + command + '</pre></td></tr>\n' | def filereport(self, uri): if not sessions.session: return '|blknopermission|' elif sessions.session.user.can_edit(doc_id=uri.id)==0: return '|blknopermission|' |
if user==None or section.registered_count==0: | if sessions.session==None or section.registered_count==0: | def sitemap(self, uri): log(3, 'Creating sitemap') box = '' box = '<table class="box" width="100%"><tr><th colspan="2">|strsitemap|</th></tr>\n' section_codes = lampadasweb.sections.sort_by('sort_order') page_codes = lampadasweb.pages.sort_by('sort_order') for section_code in section_codes: section = lampadasweb.sectio... |
if (user.admin==0 and user.sysadmin==0) or (section.admin_count==0): | if sessions.session==None: continue if (sessions.session.user.admin==0 and sessions.session.user.sysadmin==0) or (section.admin_count==0): | def sitemap(self, uri): log(3, 'Creating sitemap') box = '' box = '<table class="box" width="100%"><tr><th colspan="2">|strsitemap|</th></tr>\n' section_codes = lampadasweb.sections.sort_by('sort_order') page_codes = lampadasweb.pages.sort_by('sort_order') for section_code in section_codes: section = lampadasweb.sectio... |
if user.sysadmin==0 or section.sysadmin_count==0: | if sessions.session==None: continue if sessions.session.user.sysadmin==0 or section.sysadmin_count==0: | def sitemap(self, uri): log(3, 'Creating sitemap') box = '' box = '<table class="box" width="100%"><tr><th colspan="2">|strsitemap|</th></tr>\n' section_codes = lampadasweb.sections.sort_by('sort_order') page_codes = lampadasweb.pages.sort_by('sort_order') for section_code in section_codes: section = lampadasweb.sectio... |
if user==None: continue | if sessions.session==None: continue | def sitemap(self, uri): log(3, 'Creating sitemap') box = '' box = '<table class="box" width="100%"><tr><th colspan="2">|strsitemap|</th></tr>\n' section_codes = lampadasweb.sections.sort_by('sort_order') page_codes = lampadasweb.pages.sort_by('sort_order') for section_code in section_codes: section = lampadasweb.sectio... |
if user.admin==0 and user.sysadmin==0: | if sessions.session==None: continue if sessions.session.user.admin==0 and sessions.session.user.sysadmin==0: | def sitemap(self, uri): log(3, 'Creating sitemap') box = '' box = '<table class="box" width="100%"><tr><th colspan="2">|strsitemap|</th></tr>\n' section_codes = lampadasweb.sections.sort_by('sort_order') page_codes = lampadasweb.pages.sort_by('sort_order') for section_code in section_codes: section = lampadasweb.sectio... |
if user.sysadmin==0: | if sessions.session==None: continue if sessions.session.user.sysadmin==0: | def sitemap(self, uri): log(3, 'Creating sitemap') box = '' box = '<table class="box" width="100%"><tr><th colspan="2">|strsitemap|</th></tr>\n' section_codes = lampadasweb.sections.sort_by('sort_order') page_codes = lampadasweb.pages.sort_by('sort_order') for section_code in section_codes: section = lampadasweb.sectio... |
if os.path.isfile(uri.Filename): return self.send_File(uri.Filename) | filename = uri.Path + "/" + uri.Filename if os.path.isfile(filename): return self.send_File(filename) | def send_URI(self, uri): |
mimetype = "" | mimetype = "text/plain" | def send_File(self, filename): temp = string.split(filename, ".") if len(temp) > 1: fileext = temp[1] else: fileext = "" if os.path.isfile(filename + ".png"): fileext = "png" elif os.path.isfile(filename + ".jpeg"): fileext = "jpeg" if os.path.isfile(filename + ".jpg"): fileext = "jpg" if os.path.isfile(filename + ".gi... |
cmd_text = '\t' | cmd_text = '' if command.errors_to > '': cmd_text += '\trm -f ' + command.errors_to + '\n' | def get_text(self): dep_text = '' for key in self.dependencies: if dep_text=='': dep_text = '\t' + key else: dep_text = dep_text + ' ' + key dep_text = dep_text + '\n' cmd_text = '\t' for key in self.commands.sort_by('sort_order'): command = self.commands[key] if command.errors_to > '': cmd_text += 'rm ' + command.erro... |
if command.errors_to > '': cmd_text += 'rm ' + command.errors_to + '; ' | cmd_text += '\t' | def get_text(self): dep_text = '' for key in self.dependencies: if dep_text=='': dep_text = '\t' + key else: dep_text = dep_text + ' ' + key dep_text = dep_text + '\n' cmd_text = '\t' for key in self.commands.sort_by('sort_order'): command = self.commands[key] if command.errors_to > '': cmd_text += 'rm ' + command.erro... |
newBlock.load(row) | newBlock.load_row(row) | def __init__(self): self.data = {} sql = "SELECT block_code, block FROM block" cursor = db.select(sql) while (1): row = cursor.fetchone() if row==None: break newBlock = Block() newBlock.load(row) self.data[newBlock.code] = newBlock |
def load(self, row): | def load_row(self, row): | def load(self, row): self.code = trim(row[0]) self.block = trim(row[1]) |
sql = "SELECT section_code, sort_order, only_registered, only_admin, only_sysadmin FROM section" | sql = "SELECT section_code, sort_order, only_dynamic, only_registered, only_admin, only_sysadmin FROM section" | def __init__(self): self.data = {} sql = "SELECT section_code, sort_order, only_registered, only_admin, only_sysadmin FROM section" cursor = db.select(sql) while (1): row = cursor.fetchone() if row==None: break newSection = Section() newSection.load(row) self.data[newSection.code] = newSection |
newSection.load(row) | newSection.load_row(row) | def __init__(self): self.data = {} sql = "SELECT section_code, sort_order, only_registered, only_admin, only_sysadmin FROM section" cursor = db.select(sql) while (1): row = cursor.fetchone() if row==None: break newSection = Section() newSection.load(row) self.data[newSection.code] = newSection |
def load(self, row): | def load_row(self, row): | def load(self, row): self.code = trim(row[0]) self.sort_order = safeint(row[1]) self.only_registered = tf2bool(row[2]) self.only_admin = tf2bool(row[3]) self.only_sysadmin = tf2bool(row[4]) self.registered_count = int(db.read_value('SELECT COUNT(*) FROM page WHERE only_registered or only_admin or... |
self.only_registered = tf2bool(row[2]) self.only_admin = tf2bool(row[3]) self.only_sysadmin = tf2bool(row[4]) | self.only_dynamic = tf2bool(row[2]) self.only_registered = tf2bool(row[3]) self.only_admin = tf2bool(row[4]) self.only_sysadmin = tf2bool(row[5]) self.dynamic_count = int(db.read_value('SELECT COUNT(*) FROM page WHERE only_dynamic')) | def load(self, row): self.code = trim(row[0]) self.sort_order = safeint(row[1]) self.only_registered = tf2bool(row[2]) self.only_admin = tf2bool(row[3]) self.only_sysadmin = tf2bool(row[4]) self.registered_count = int(db.read_value('SELECT COUNT(*) FROM page WHERE only_registered or only_admin or... |
sql = "SELECT page_code, section_code, sort_order, template_code, data, only_registered, only_admin, only_sysadmin FROM page" | sql = "SELECT page_code, section_code, sort_order, template_code, data, only_dynamic, only_registered, only_admin, only_sysadmin FROM page" | def __init__(self): self.data = {} sql = "SELECT page_code, section_code, sort_order, template_code, data, only_registered, only_admin, only_sysadmin FROM page" cursor = db.select(sql) while (1): row = cursor.fetchone() if row==None: break newPage = Page() newPage.load(row) self.data[newPage.code] = newPage |
newPage.load(row) | newPage.load_row(row) | def __init__(self): self.data = {} sql = "SELECT page_code, section_code, sort_order, template_code, data, only_registered, only_admin, only_sysadmin FROM page" cursor = db.select(sql) while (1): row = cursor.fetchone() if row==None: break newPage = Page() newPage.load(row) self.data[newPage.code] = newPage |
def load(self, row): | def load_row(self, row): | def load(self, row): self.code = trim(row[0]) self.section_code = trim(row[1]) self.sort_order = safeint(row[2]) self.template_code = trim(row[3]) self.data = trim(row[4]).split() self.only_registered = tf2bool(row[5]) self.only_admin = tf2bool(row[6]) self.only_sysadmin = tf2bool(ro... |
self.only_registered = tf2bool(row[5]) self.only_admin = tf2bool(row[6]) self.only_sysadmin = tf2bool(row[7]) | self.only_dynamic = tf2bool(row[5]) self.only_registered = tf2bool(row[6]) self.only_admin = tf2bool(row[7]) self.only_sysadmin = tf2bool(row[8]) | def load(self, row): self.code = trim(row[0]) self.section_code = trim(row[1]) self.sort_order = safeint(row[2]) self.template_code = trim(row[3]) self.data = trim(row[4]).split() self.only_registered = tf2bool(row[5]) self.only_admin = tf2bool(row[6]) self.only_sysadmin = tf2bool(ro... |
newString.load(row) | newString.load_row(row) | def __init__(self): self.data = {} sql = "SELECT string_code FROM string" cursor = db.select(sql) while (1): row = cursor.fetchone() if row==None: break newString = String() newString.load(row) self.data[newString.code] = newString |
def load(self, row): | def load_row(self, row): | def load(self, row): self.code = trim(row[0]) sql = "SELECT lang, string FROM string_i18n WHERE string_code=" + wsq(self.code) cursor = db.select(sql) while (1): row = cursor.fetchone() if row==None: break lang = row[0] self.string[lang] = trim(row[1]) |
newTemplate.load(row) | newTemplate.load_row(row) | def __init__(self): self.data = {} sql = "SELECT template_code, template FROM template" cursor = db.select(sql) while (1): row = cursor.fetchone() if row==None: break newTemplate = Template() newTemplate.load(row) self.data[newTemplate.code] = newTemplate |
def load(self, row): | def load_row(self, row): | def load(self, row): self.code = trim(row[0]) self.template = trim(row[1]) |
username CHAR(20) NOT NULL, first_name CHAR(20), surname CHAR(20), maintainer_id INT4, email TEXT, admin BOOLEAN, editor_id INT4, | user_id INT4 NOT NULL, username CHAR(20) NOT NULL UNIQUE, session_id CHAR(20), first_name CHAR(20), middle_name CHAR(20), surname CHAR(20), email TEXT, admin BOOLEAN, password CHAR(12), notes TEXT, | def get_connection(name) : from pyPgSQL import PgSQL return PgSQL.connect(database=name) |
PRIMARY KEY (username) | PRIMARY KEY (user_id) | def get_connection(name) : from pyPgSQL import PgSQL return PgSQL.connect(database=name) |
INSERT INTO username ( username, first_name, surname, email ) VALUES ( %(username)s, %(first_name)s, %s(surname), %(email)s ) | INSERT INTO username (user_id, username, first_name, surname, email, admin ) VALUES ('1', '%(username)s', '%(first_name)s', '%(surname)s', '%(email)s', TRUE ) | def get_connection(name) : from pyPgSQL import PgSQL return PgSQL.connect(database=name) |
def setUp(self): self.con = get_connection(DBNAME) try: self.con.cursor().execute(SQL_CREATE) except Exception, e : print e self.con.cursor().execute('delete from %s'%TABLE) self.con.commit() self.con.cursor().execute(SQL_INSERT, DATA_INSERT) self.con.commit() self.db = DataLayer.PgSQLDatabase(DBNAME) | def setUp(self): self.con = get_connection(DBNAME) try: self.con.cursor().execute(SQL_CREATE) except Exception, e : print e self.con.cursor().execute('delete from username') self.con.commit() self.con.cursor().execute(SQL_INSERT % DATA_INSERT) self.con.commit() self.db = DataLayer.get_database('pgsql', DBNAME) | def setUp(self): self.con = get_connection(DBNAME) try: self.con.cursor().execute(SQL_CREATE) except Exception, e : print e self.con.cursor().execute('delete from %s'%TABLE) self.con.commit() self.con.cursor().execute(SQL_INSERT, DATA_INSERT) self.con.commit() self.db = DataLayer.PgSQLDatabase(DBNAME) |
def tearDown(self) : self.con.cursor().execute(DROP_TABLE) self.con.commit() self.con.close() def test_get_user(self): u = self.db.get_user('david') self.assert_(isinstance(u,User)) self.assert_(u.name == 'david') | def tearDown(self) : pass def test_get_user(self): u = self.db.get_user_by_name('david') self.assert_(isinstance(u,DataLayer.User)) self.assert_(u.username == 'david') self.assert_(u.firstname == 'David') self.assert_(u.surname == '') self.assert_(u.name == 'Merrill') self.assert_(u.email == 'david@lupercalia.net')... | def tearDown(self) : self.con.cursor().execute(DROP_TABLE) self.con.commit() self.con.close() |
if self.data_type in ('sequence', 'int', 'float'): return 0 if self.data_type in ('string', ''): return '' if self.data_type=='time': return '' if self.data_type=='date': return '' if self.data_type=='bool': return 0 if self.data_type=='created': return now_string() ... | if self.data_type in ('sequence', 'int', 'float'): return 0 elif self.data_type in ('string', ''): return '' elif self.data_type=='time': return '' elif self.data_type=='date': return '' elif self.data_type=='bool': return 0 elif self.data_type=='created': return now_string() elif s... | def get_default(self): if self.data_type in ('sequence', 'int', 'float'): return 0 if self.data_type in ('string', ''): return '' if self.data_type=='time': return '' if self.data_type=='date': return '' if self.data_type=='bool': return 0 if self.data_type=='created': ... |
if self.data_type in ('sequence', 'int', 'float'): return safeint(value) if self.data_type in ('string', ''): return trim(value) if self.data_type=='time': return time2str(value) if self.data_type=='date': return date2str(value) if self.data_type=='bool': return tf2bool(value)... | if self.data_type in ('sequence', 'int', 'float'): return safeint(value) elif self.data_type in ('string', ''): return trim(value) elif self.data_type=='time': return time2str(value) elif self.data_type=='date': return date2str(value) elif self.data_type=='bool': return tf2bool(value) elif... | def field_to_attr(self, value): if self.data_type in ('sequence', 'int', 'float'): return safeint(value) if self.data_type in ('string', ''): return trim(value) if self.data_type=='time': return time2str(value) if self.data_type=='date': return date2str(value) if self.data_type=='bool': ... |
if self.data_type=='string': return wsq(str(value)) if self.data_type=='bool': return wsq(bool2tf(value)) if self.data_type=='date': return wsq(str(value)) if self.data_type=='time': return wsq(str(value)) if self.data_type=='created': return wsq(str(value)) if self.data_type=='updated': return wsq(now_string... | elif self.data_type=='string': return wsq(str(value)) elif self.data_type=='bool': return wsq(bool2tf(value)) elif self.data_type=='date': return wsq(str(value)) elif self.data_type=='time': return wsq(str(value)) elif self.data_type=='created': return wsq(str(value)) elif self.data_type=='updated': return ws... | def attr_to_field(self, value): if self.data_type in ('sequence', 'int', 'float'): if self.nullable==1 and value==0: return 'NULL' else: return str(value) if self.data_type=='string': return wsq(str(value)) if self.data_type=='bool': return wsq(bool2tf(value)) if self.data_type=='date': return wsq(str(value)) if... |
the second string the returned tuple wil be ''. | the second string the returned tuple will be ''. | def splitterm(term, sep): """ Splits the term into 2 pieces according to the seperator, and returns them. If the term does not contain the sep, the second string the returned tuple wil be ''. """ temp = string.split(term, sep, 1) if len(temp) > 1: return temp[0], temp[1] else: return temp[0], '' |
raise ConfigFileReadErrorException(msg + filename + " not found.") | raise ConfigFileReadError(msg + filename + " not found.") | def get_config_filepath() : """ Returns filepath of config file. Respects LAMPADAS_ETC env variable. """ import os msg = '' filename = os.getenv('LAMPADAS_ETC') if filename==None: filename = '/etc/lampadas' msg = 'Environment variable LAMPADAS_ETC is undefined.\n' filename += '/lampadas.conf' if not os.access(filename... |
raise ConfigFileReadErrorException("File '%s' is missing or does not" " contain a '%s' section" % (self.config_file,section)) | raise ConfigFileReadError("Section %s is missing"%section) | def _read_var(self, section, name): if not self.parser.has_section(section) : raise ConfigFileReadErrorException("File '%s' is missing or does not" " contain a '%s' section" % (self.config_file,section)) |
raise ConfigFileReadErrorException("Can't read option '%s' from section %s of file %s" % (name, section, self.config_file)) | raise ConfigFileReadError("Can't read option '%s' from section %s" % (name, section)) | def _read_var(self, section, name): if not self.parser.has_section(section) : raise ConfigFileReadErrorException("File '%s' is missing or does not" " contain a '%s' section" % (self.config_file,section)) |
config = config_reader.read_config(open(config_file)) | try: config = config_reader.read_config(open(config_file)) except ConfigFileReadError, e: raise ConfigFileReadError("File %s: %s" % (config_file,e.msg)) | def _read_var(self, section, name): if not self.parser.has_section(section) : raise ConfigFileReadErrorException("File '%s' is missing or does not" " contain a '%s' section" % (self.config_file,section)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.