rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
self.CreateItems() | def __SetData(self): if DEBUG: print >> sys.stderr, "ListBody: set data", time() data = self.raw_data #apply quickfilter if self.filter != '': data = filter(self.MatchFilter, data) self.parent_list.SetFilteredResults(len(data)) self.vSizer.Clear() if data: if len(self.items) == 0: #new data if len(data) > LIST_ITEM_B... | |
return len(data) return 0 | def __SetData(self): if DEBUG: print >> sys.stderr, "ListBody: set data", time() data = self.raw_data #apply quickfilter if self.filter != '': data = filter(self.MatchFilter, data) self.parent_list.SetFilteredResults(len(data)) self.vSizer.Clear() if data: if len(self.items) == 0: #new data if len(data) > LIST_ITEM_B... | |
self.vlcwrap = vlcwrap | def __init__(self, parent, utility, vlcwrap, bg, border = True): wx.Panel.__init__(self, parent, -1) self.utility = utility self.parent = parent self.border = border self.SetBackgroundColour(wx.WHITE) self.volume = 0.48 self.oldvolume = 0.48 self.estduration = None | |
self.vlcwrap = vlcwrap | def __init__(self, parent, utility, vlcwrap, bg, border = True): wx.Panel.__init__(self, parent, -1) self.utility = utility self.parent = parent self.border = border self.SetBackgroundColour(wx.WHITE) self.volume = 0.48 self.oldvolume = 0.48 self.estduration = None | |
selected_fields = 'term' | selected_fields = 'term', min_freq = 2 | def __init__(self): if NetworkBuzzDBHandler.__single is not None: raise RuntimeError, "NetworkBuzzDBHandler is singleton" NetworkBuzzDBHandler.__single = self db = SQLiteCacheDB.getInstance() BasicDBHandler.__init__(self,db, 'TermFrequency') from Tribler.Core.Tag.Extraction import TermExtraction self.extractor = TermE... |
selected_fields = 'phrase' | selected_fields = 'phrase', min_freq = 1 | def __init__(self): if NetworkBuzzDBHandler.__single is not None: raise RuntimeError, "NetworkBuzzDBHandler is singleton" NetworkBuzzDBHandler.__single = self db = SQLiteCacheDB.getInstance() BasicDBHandler.__init__(self,db, 'TermFrequency') from Tribler.Core.Tag.Extraction import TermExtraction self.extractor = TermE... |
(self.MIN_FREQ, max(self.MIN_FREQ, a)) | (min_freq, a) | def getBuzzForTable(self, table, size, with_freq=True, max_freq=None): """ Retrieves a sample of high, medium and low frequent terms or phrases, paired with their frequencies, depending on the table to be sampled from. @table Table to retrieve the highest frequency from. Must be a key in NetworkBuzzDBHandler.TABLES. @... |
self.requestingThreads[prio] = TorrentRequester(self.metadatahandler, self.overlay_bridge, prio) | self.requestingThreads[prio] = TorrentRequester(self.metadatahandler, self.overlay_bridge, self.session, prio) | def download_torrent(self,permid,infohash,usercallback, prio = 1): """ The user has selected a torrent referred to by a peer in a query reply. Try to obtain the actual .torrent file from the peer and then start the actual download. """ assert isinstance(infohash, str), "INFOHASH has invalid type: %s" % type(infohash) a... |
def __init__(self, metadatahandler, overlay_bridge, prio): | def __init__(self, metadatahandler, overlay_bridge, session, prio): | def __init__(self, metadatahandler, overlay_bridge, prio): self.metadatahandler = metadatahandler self.overlay_bridge = overlay_bridge self.prio = prio self.queue = Queue.Queue() self.sources = {} self.doRequest() |
self.searchField = TextCtrlAutoComplete(self, entrycallback = self.complete, selectcallback = self.OnAutoComplete) | if sys.platform == 'darwin': self.searchField = wx.SearchCtrl(self, -1, "", style=wx.TE_PROCESS_ENTER) self.searchField.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, self.OnSearchKeyDown) else: self.searchField = TextCtrlAutoComplete(self, entrycallback = self.complete, selectcallback = self.OnAutoComplete) | def _PostInit(self): if DEBUG: print >> sys.stderr, "TopSearchPanel: OnCreate" bgPanel._PostInit(self) self.SetBackgroundColour(wx.Colour(255, 255, 255)) """ if sys.platform == 'linux2': #bug in linux for searchctrl, focus does not hide search text + text stays grey self.searchField = wx.TextCtrl(self, -1, "", style... |
old_term_ids = self.getTorrentSearchTerms(torrent_id, peer_id) sql_update_term_popularity= u"UPDATE ClicklogTerm SET times_seen = times_seen-1 WHERE term_id=?" self._db.executemany(sql_update_term_popularity, old_term_ids, commit=commit) self._db.execute_write("DELETE FROM ClicklogSearch WHERE peer_id=? AND torrent_id... | def storeKeywordsByID(self, peer_id, torrent_id, term_ids, commit=True): sql_insert_search = u"INSERT INTO ClicklogSearch (peer_id, torrent_id, term_id, term_order) values (?, ?, ?, ?)" if len(term_ids)>MAX_KEYWORDS_STORED: term_ids= term_ids[0:MAX_KEYWORDS_STORED] | |
self.dslist = [] | def __init__(self,guiUtility): if TorrentManager.__single: raise RuntimeError, "TorrentSearchGridManager is singleton" TorrentManager.__single = self self.guiUtility = guiUtility # Contains all matches for keywords in DB, not filtered by category self.hits = [] # Remote results for current keywords self.remoteHits = ... | |
self._db.executemany(u"INSERT OR REPLACE INTO InvertedIndex VALUES(?, ?)", values, commit=False) | self.executemany(u"INSERT OR REPLACE INTO InvertedIndex VALUES(?, ?)", values, commit=False) | torrentdef = TorrentDef.load(abs_filename) |
if address in self._connections: | already_on_this_address = False for connection in self._connections: if connection.address == address: already_on_this_address = True break if already_on_this_address: | def _create_connections(self): # order by last connection attempt addresses = [(timestamp, address) for address, timestamp in self._potential_peers.iteritems()] addresses.sort() |
@return Whether of not the specified permid is a superpeer. | @return Whether of not the specified permid is a crawler. | def isCrawler(self, permid): """ @param permid The permid of the sending peer. @return Whether of not the specified permid is a superpeer. """ return permid in self.session.lm.crawler_db.getCrawlers() |
addresses = [(timestamp, address) for address, timestamp in self._potential_peers.iteritems()] | addresses = [(timestamp, address) for address, timestamp in self._potential_peers.iteritems() if timestamp + 60 > now] | def _create_connections(self): # order by last connection attempt addresses = [(timestamp, address) for address, timestamp in self._potential_peers.iteritems()] addresses.sort() |
now = time() | def _create_connections(self): # order by last connection attempt addresses = [(timestamp, address) for address, timestamp in self._potential_peers.iteritems()] addresses.sort() | |
pass | if DEBUG: print >> sys.stderr, "videoplaybackcrawler: handle_info_crawler_request", show_permid_short(permid), message try: cursor = self._event_db._db.execute_read(message) except Exception, e: reply_callback(str(e), error=1) else: if cursor: reply_callback(zlib.compress(cPickle.dumps(list(cursor), 2), 9)) else: re... | def handle_info_crawler_request(self, permid, selversion, channel_id, message, reply_callback): pass |
self._file.write("; ".join((strftime("%Y/%m/%d %H:%M:%S"), " INFO REQUEST", show_permid(permid), "\n"))) | self._file.write("; ".join((strftime("%Y/%m/%d %H:%M:%S"), " EVENT REQUEST", show_permid(permid), "\n"))) | def _after_event_request_callback(self, exc, permid): """ <<Crawler-side>> Called by the Crawler with the result of the request_callback call in the handle_crawler_reply method. """ if not exc: if DEBUG: print >>sys.stderr, "videoplaybackcrawler: request send to", show_permid_short(permid) self._file.write("; ".join((s... |
print statement | def insert_data_from_file(self, filename): """Perform a bulk insert.""" if (self.table.cleanup.function == no_cleanup and self.table.header_rows < 2) and (self.table.delimiter in ["\t", ","]): print ("Inserting data from " + os.path.basename(filename) + " . . .") if self.table.delimiter == "\t": fmt = "TabDelimited" e... | |
else: mode = 'ab' initial = "\n" | def AddDataset(self, evt): # Run Add Dataset wizard add_dataset = AddDatasetWizard(self.Parent, -1, 'Add Dataset') if add_dataset.RunWizard(add_dataset.page[0]): dataset_url = add_dataset.url.GetValue() dbname = add_dataset.dbname.GetValue() tablename = add_dataset.tablename.GetValue() if not tablename: tablename = dbn... | |
id = 1 | id = self.table.record_id | def insert_data_from_file(self, filename): """Perform a bulk insert.""" if (self.table.cleanup.function == no_cleanup and self.table.header_rows < 2) and (self.table.delimiter in ["\t", ","]): print ("Inserting data from " + os.path.basename(filename) + " . . .") if self.table.delimiter == "\t": fmt = "TabDelimited" e... |
self.connection.rollback() | raise self.connection.rollback() | def insert_data_from_file(self, filename): """Perform a bulk insert.""" if (self.table.cleanup.function == no_cleanup and self.table.header_rows < 2) and (self.table.delimiter in ["\t", ","]): print ("Inserting data from " + os.path.basename(filename) + " . . .") if self.table.delimiter == "\t": fmt = "TabDelimited" e... |
RAW_DATA_LOCATION = "raw_data2" | def download(self, engine=None): # Variables to get text file/create database engine = self.checkengine(engine) RAW_DATA_LOCATION = "raw_data2" db = Database() db.dbname = "AvianBodyMass" engine.db = db engine.get_cursor() engine.create_db() table = Table() table.tablename = "mass" table.delimiter = ",," table.clean... | |
self.engine.auto_create_table(self.tables[key], url=value) self.engine.insert_data_from_url(value) | self.engine.auto_create_table(self.tables[key], url=value) self.engine.insert_data_from_url(value) self.tables[key].record_id = 0 | def download(self, engine=None): DbTk.download(self, engine) for key in self.urls.keys(): if not key in self.tables.keys(): self.tables[key] = Table(key, cleanup=Cleanup(correct_invalid_value, nulls=[-999])) for key, value in self.urls.items(): self.engine.auto_create_table(self.tables[key], url=value) self.engine.in... |
type += "(" + datatype[1] + ")" | type += "(" + str(datatype[1]) + ")" | def convert_data_type(engine, datatype): """Converts DBTK generic data types to db engine specific data types""" datatypes = dict() datatypes["pk"], datatypes["int"], datatypes["double"], datatypes["char"], datatypes["bit"] = range(5) datatypes["combine"], datatypes["skip"] = [-1, -1] dbdatatypes = dict() dbdatatypes["... |
db.opts["password"] = getpass.getpass("Enter your MySQL password: ") | print "Enter your MySQL password: " db.opts["password"] = getpass.getpass(" ") | def get_cursor_mysql(db): """Get login information for MySQL database""" import MySQLdb as dbapi # If any parameters are missing, input them manually if db.opts["username"] == "": db.opts["username"] = raw_input("Enter your MySQL username: ") if db.opts["password"] == "": db.opts["password"] = getpass.getpass("Enter y... |
print values | def extract_values(self, line): if self.table.fixedwidth: pos = 0 values = [] for width in self.table.fixedwidth: values.append(line[pos:pos+width].strip()) pos += width print values return values else: return line.split(self.table.delimiter) | |
"Access databases (*.mdb, *.accdb)|*.mdb,*.accdb"]] | "Access databases (*.mdb, *.accdb)|*.mdb;*.accdb"]] | def get_cursor(self): """Gets the db connection and cursor.""" import sqlite3 as dbapi self.get_input() self.connection = dbapi.connect(self.opts["file"]) self.cursor = self.connection.cursor() |
def __init__(self, parent, id, txt="", size=(-1,-1), style=None): wx.TextCtrl.__init__(self, parent, id, txt, size=size, style=0) | def __init__(self, parent, id, txt="", size=(-1,-1), style=0): wx.TextCtrl.__init__(self, parent, id, txt, size=size, style=style) | def __init__(self, parent, id, txt="", size=(-1,-1), style=None): wx.TextCtrl.__init__(self, parent, id, txt, size=size, style=0) self.SetForegroundColour(wx.BLACK) self.SetBackgroundColour(wx.WHITE) |
line = input_file.readline() | line = datain.readline() | def emptyvaltonull(datain): """Convert empty fields in comma delimited text to MySQL NULL indicator /N Keyword arguments: datain = a list of strings where each string is one line of the datafile """ # TO DO - test new implementation # TO DO - add ability to select delimiter other than commas dataout = []; line = dat... |
try: engine = page[2].engine except Exception as e: wx.MessageBox("There was an error with your database connection. \n\n" + e.__str__()) raise options = page[2].option engine.keep_raw_data = page[1].keepdata.Value engine.use_local = page[1].uselocal opts = dict() for key in options.keys(): opts[key] = options[key].Get... | def CheckValues(self, evt): """Users can't continue from this page without checking at least one dataset.""" if len(self.scriptlist.GetCheckedStrings()) == 0 and evt.Direction: evt.Veto() elif evt.Direction: checked = self.scriptlist.GetCheckedStrings() warn = [script.name for script in dbtk_list if not script.public a... | |
"Downloading . . ." + | "Connecting to database . . ." + | def CheckValues(self, evt): """Users can't continue from this page without checking at least one dataset.""" if len(self.scriptlist.GetCheckedStrings()) == 0 and evt.Direction: evt.Veto() elif evt.Direction: checked = self.scriptlist.GetCheckedStrings() warn = [script.name for script in dbtk_list if not script.public a... |
class UserSkipped(Exception): pass class UserAborted(Exception): pass | def CheckValues(self, evt): """Users can't continue from this page without checking at least one dataset.""" if len(self.scriptlist.GetCheckedStrings()) == 0 and evt.Direction: evt.Veto() elif evt.Direction: checked = self.scriptlist.GetCheckedStrings() warn = [script.name for script in dbtk_list if not script.public a... | |
if (empty_cols >= cols - 1 or excel.cell_value(row[0]) == "Scientific Name" or excel.cell_value(row[0])[0:7] == "Species"): | if ((empty_cols == cols) or excel.cell_value(row[0]) == "Scientific Name" or excel.cell_value(row[0])[0:7] == "Species"): pass elif empty_cols == cols - 1: | def sci_name(value): """Returns genus/species/subspecies list from a scientific name""" values = value.split() list = [] if len(values) >= 2: [list.append(value) for value in values[0:2]] if len(values) == 3: list.append(values[2]) while len(list) < 3: list.append('') return list |
if not values[5]: values[5] = lastvalues[5] | if not values[12]: if lastvalues: if lastvalues[5]: if lastvalues[5] == "Male" and values[5] == "Female": values[12] = lastvalues[12] | def sci_name(value): """Returns genus/species/subspecies list from a scientific name""" values = value.split() list = [] if len(values) >= 2: [list.append(value) for value in values[0:2]] if len(values) == 3: list.append(values[2]) while len(list) < 3: list.append('') return list |
if (empty_cols >= cols - 1 or row[0].value.strip() == "Scientific Name" or row[0].value.strip()[0:7] == "Species"): | if (empty_cols >= cols - 1 or cellvalue(row[0]) == "Scientific Name" or cellvalue(row[0])[0:7] == "Species"): | def empty(cell): return cell.ctype == 0 |
values.append(str(lastrow[0].value.strip())) values.append(str(lastrow[1].value.strip())) | values.append(cellvalue(lastrow[0])) values.append(cellvalue(lastrow[1])) | def empty(cell): return cell.ctype == 0 |
values.append(str(row[0].value.strip())) values.append(str(row[1].value.strip())) | if len(cellvalue(row[0]).split()) == 1: values.append(cellvalue(lastrow[0]).split()[0] + " " + cellvalue(row[0])) else: values.append(cellvalue(row[0])) values.append(cellvalue(row[1])) | def empty(cell): return cell.ctype == 0 |
if row[2].value == "M": | if cellvalue(row[2]) == "M": | def empty(cell): return cell.ctype == 0 |
elif row[2].value == "F": | elif cellvalue(row[2]) == "F": | def empty(cell): return cell.ctype == 0 |
elif row[2].value == "B": | elif cellvalue(row[2]) == "B": | def empty(cell): return cell.ctype == 0 |
elif row[2].value == "U": | elif cellvalue(row[2]) == "U": | def empty(cell): return cell.ctype == 0 |
values.append(str(row[2].value).strip()) | values.append(cellvalue(row[2])) | def empty(cell): return cell.ctype == 0 |
values.append(str(row[i].value).strip()) | values.append(cellvalue(row[i])) | def empty(cell): return cell.ctype == 0 |
line = main_table.readline() | if table.header_rows > 0: for i in range(table.header_rows): line = main_table.readline() | def create_table(db, table): """Creates a database based on settings supplied in dbinfo object""" warnings.filterwarnings("ignore") # Connect to the database if db.engine == "postgresql": object = "SCHEMA" else: object = "DATABASE" if db.drop: db.cursor.execute(drop_statement(db.engine, object, db.dbname)) db.cursor.... |
type = mydatatypes[datatypes[datatype[0]]] if len(datatype) > 1 and "%s" in type: type = type % datatype[1] | thisvartype = datatypes[datatype[0]] if thisvartype > -1: type = mydatatypes[thisvartype] if len(datatype) > 1 and "%s" in type: type = type % datatype[1] else: type = datatype[0] | def convert_data_type(engine, datatype): datatypes = dict() datatypes["pk"], datatypes["int"], datatypes["double"], datatypes["char"], datatypes["bit"] = range(5) datatypes["combine"], datatypes["skip"] = [-1, -1] dbdatatypes = dict() dbdatatypes["mysql"] = ["INT(5) NOT NULL AUTO_INCREMENT", "INT(%s)", "DOUBLE", "VARCH... |
self.html += "<font color='green'>" + s.split(':')[0] + "</font>" | self.html += "\n<p><font color='green'>" + s.split(':')[0] + "</font></p>" | def write(self, s): if '\b' in s: s = s.replace('\b', '') if not self.dialog: self.html += "<font color='green'>" + s.split(':')[0] + "</font>" self.refresh_html() wx.GetApp().Yield() self.dialog = wx.ProgressDialog("Download Progress", "Downloading datasets . . .\n" + " " * len(s), maximum=2, parent=self.Parent, styl... |
maximum=2, | maximum=100, | def write(self, s): if '\b' in s: s = s.replace('\b', '') if not self.dialog: self.html += "<font color='green'>" + s.split(':')[0] + "</font>" self.refresh_html() wx.GetApp().Yield() self.dialog = wx.ProgressDialog("Download Progress", "Downloading datasets . . .\n" + " " * len(s), maximum=2, parent=self.Parent, styl... |
self.dialog.Update(2, "") | self.dialog.Update(100, "") | def write(self, s): if '\b' in s: s = s.replace('\b', '') if not self.dialog: self.html += "<font color='green'>" + s.split(':')[0] + "</font>" self.refresh_html() wx.GetApp().Yield() self.dialog = wx.ProgressDialog("Download Progress", "Downloading datasets . . .\n" + " " * len(s), maximum=2, parent=self.Parent, styl... |
self.dialog.Update(2, "") | self.dialog.Update(1000, "") | def write(self, s): if '\b' in s: s = s.replace('\b', '') if not self.dialog: self.html += "<font color='green'>" + s.split(':')[0] + "</font>" self.refresh_html() wx.GetApp().Yield() self.dialog = wx.ProgressDialog("Download Progress", "Downloading datasets . . .\n" + " " * len(s), maximum=2, parent=self.Parent, styl... |
parent.TitledPage.__init__(self, parent, title, label) self.checkallbox = wx.CheckBox(self, -1, "All") self.sizer.Add(self.checkallbox) self.checkallbox.Bind(wx.EVT_CHECKBOX, self.CheckAll) | parent.TitledPage.__init__(self, parent, title, label) | def __init__(self, parent, title, label): parent.TitledPage.__init__(self, parent, title, label) # All checkbox self.checkallbox = wx.CheckBox(self, -1, "All") self.sizer.Add(self.checkallbox) self.checkallbox.Bind(wx.EVT_CHECKBOX, self.CheckAll) # CheckListBox of scripts lists = [list.name for list in parent.lists] se... |
self.sizer.Add(self.catlist) | self.sizer.Add(self.catlist, 0, wx.EXPAND) | def __init__(self, parent, title, label): parent.TitledPage.__init__(self, parent, title, label) # All checkbox self.checkallbox = wx.CheckBox(self, -1, "All") self.sizer.Add(self.checkallbox) self.checkallbox.Bind(wx.EVT_CHECKBOX, self.CheckAll) # CheckListBox of scripts lists = [list.name for list in parent.lists] se... |
def CheckAll(self, evt): if self.checkallbox.GetValue(): self.catlist.SetCheckedStrings([list.name for list in self.Parent.lists]) else: self.catlist.SetCheckedStrings([]) | def CheckAll(self, evt): if self.checkallbox.GetValue(): self.catlist.SetCheckedStrings([list.name for list in self.Parent.lists]) else: self.catlist.SetCheckedStrings([]) | |
self.sizer.Add(self.scriptlist) | self.sizer.Add(self.scriptlist, 0, wx.EXPAND) | def __init__(self, parent, title, label): parent.TitledPage.__init__(self, parent, title, label) # Check that at least one dataset is selected before proceeding self.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGING, self.CheckValues) # All checkbox self.checkallbox = wx.CheckBox(self, -1, "All") self.checkallbox.SetValue(True) ... |
if excel.empty_cell(row[0]) and excel.empty_cell(row[1]) and empty_cols < (cols - 1): [values.append(value) for value in sci_name(excel.cell_value(lastrow[1]))] values.append(excel.cell_value(lastrow[2])) | if excel.empty_cell(row[0]) and excel.empty_cell(row[1]): [values.append(value) for value in sci_name(excel.cell_value(lastrow[0]))] values.append(excel.cell_value(lastrow[1])) | def sci_name(value): """Returns genus/species/subspecies list from a scientific name""" values = value.split() list = [] if len(values) >= 2: [list.append(value) for value in values[0:2]] if len(values) == 3: list.append(values[2]) while len(list) < 3: list.append('') return list |
self.write(self.worker.output[0]) | if self.write(self.worker.output[0]) == False: terminate = True | def update(self, evt): self.timer.Stop() if self.worker: self.worker.output_lock.acquire() while len(self.worker.output) > 0: self.write(self.worker.output[0]) self.worker.output = self.worker.output[1:] self.gauge.SetValue(100 * ((self.worker.scriptnum) / (self.worker.progress_max + 1.0))) if not self.worker.finished(... |
self.Parent.Abort(None) | return False | def progress(s): if ' / ' in s: s = s.split(' / ') total = float(s[1]) current = float(s[0].split(': ')[1]) progress = int((current / total) * 100) if progress < 1: return 1 else: return progress else: return None |
if self.table.pk and not self.table.hasindex: | if self.table.pk and not self.table.contains_pk: | def insert_data_from_file(self, filename): """Perform a bulk insert.""" if (self.table.cleanup.function == no_cleanup and not self.table.fixed_width and self.table.header_rows < 2) and (self.table.delimiter in ["\t", ","]): print ("Inserting data from " + os.path.basename(filename) + "...") if self.table.delimiter == ... |
sys.stdout = sys.__stdout__ | def progress(s): if ' / ' in s: s = s.split(' / ') total = float(s[1]) current = float(s[0].split(': ')[1]) progress = int((current / total) * 100) if progress < 1: return 1 else: return progress else: return None | |
return int((current / total) * 100) | progress = int((current / total) * 100) if progress < 1: return 1 else: return progress | def progress(s): if ' / ' in s: s = s.split(' / ') total = float(s[1]) current = float(s[0].split(': ')[1]) return int((current / total) * 100) else: return None |
wx.MessageBox(e, "Error") | wx.MessageBox(e.__str__(), "Error") | def write(self, s): txt = s.strip().translate(None, "\b") if txt: (keepgoing, skip) = dialog.Update(scriptnum - 1, msg + "\n" + txt) if not keepgoing: raise UserAborted if skip: raise UserSkipped |
self.SetBackgroundColour(wx.WHITE) | self.SetBackgroundColour(parent.Parent.bgcolor) | def __init__(self, parent, id, label): wx.CheckBox.__init__(self, parent, id, label) self.SetForegroundColour(wx.BLACK) self.SetBackgroundColour(wx.WHITE) |
self.engine.download_files_from_archive(self.urls[0][0], filelist) | self.engine.download_files_from_archive(self.urls[0][1], filelist) | def download(self, engine=None): DbTk.download(self, engine) self.engine.download_file(self.urls[0][1], "all_Excel.zip") local_zip = zipfile.ZipFile(self.engine.format_filename("all_Excel.zip")) filelist = local_zip.namelist() local_zip.close() self.engine.download_files_from_archive(self.urls[0][0], filelist) fileli... |
"Connecting to database . . ." + | "Downloading datasets . . ." + | def CheckValues(self, evt): """Users can't continue from this page without checking at least one dataset.""" if len(self.scriptlist.GetCheckedStrings()) == 0 and evt.Direction: evt.Veto() elif evt.Direction: checked = self.scriptlist.GetCheckedStrings() warn = [script.name for script in dbtk_list if not script.public a... |
(keepgoing, skip) = dialog.Update(scriptnum - 1, | prog = scriptnum - 1 if prog < 0: prog = 0 (keepgoing, skip) = dialog.Update(prog, | def write(self, s): txt = s.strip().translate(None, "\b") if txt: (keepgoing, skip) = dialog.Update(scriptnum - 1, msg + "\n" + txt) if not keepgoing: raise UserAborted if skip: raise UserSkipped |
msg = "Connecting to database:" print "Connecting . . ." | def write(self, s): txt = s.strip().translate(None, "\b") if txt: (keepgoing, skip) = dialog.Update(scriptnum - 1, msg + "\n" + txt) if not keepgoing: raise UserAborted if skip: raise UserSkipped | |
need_to_download = True | need_to_download = False | def write(self, s): try: filename = s.split('-')[1] msg = "Downloading " + filename + "..." s = int(s.split('-')[0]) if s < 1: s = 1 (keepgoing, skip) = self.parent.Update(s, msg) if not keepgoing: abort = True except: pass |
new_module = imp.load_module(script, file, pathname, desc) need_to_download = more_recent(new_module.VERSION, script_version) except: | new_module = imp.load_module(script_name, file, pathname, desc) need_to_download = more_recent(script_version, new_module.VERSION) except: | def write(self, s): try: filename = s.split('-')[1] msg = "Downloading " + filename + "..." s = int(s.split('-')[0]) if s < 1: s = 1 (keepgoing, skip) = self.parent.Update(s, msg) if not keepgoing: abort = True except: pass |
self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer) self.timer.Start(1) def OnTimer(self, evt): | def __init__(self): wx.Frame.__init__(self, None, title="") self.progressMax = 100 self.count = 0 | |
wx.PD_CAN_SKIP | | def __init__(self): wx.Frame.__init__(self, None, title="") self.progressMax = 100 self.count = 0 | |
btn_skip = False | def write(self, s): txt = s.strip().replace("\b", "") if txt: prog = scriptnum if prog < 1: prog = 1 btn_skip = False (keepgoing, skip) = self.frame.dialog.Update(prog, msg + "\n" + txt) if not keepgoing: raise UserAborted #if skip: # wx.MessageBox("SKIP") # raise UserSkipped | |
if skip: wx.MessageBox("SKIP") raise UserSkipped | def write(self, s): txt = s.strip().replace("\b", "") if txt: prog = scriptnum if prog < 1: prog = 1 btn_skip = False (keepgoing, skip) = self.frame.dialog.Update(prog, msg + "\n" + txt) if not keepgoing: raise UserAborted #if skip: # wx.MessageBox("SKIP") # raise UserSkipped | |
frame.Show() app.MainLoop() frame.Destroy() wizard.Destroy() | frame.Show(False) app.MainLoop() | def write(self, s): txt = s.strip().replace("\b", "") if txt: prog = scriptnum if prog < 1: prog = 1 btn_skip = False (keepgoing, skip) = self.frame.dialog.Update(prog, msg + "\n" + txt) if not keepgoing: raise UserAborted #if skip: # wx.MessageBox("SKIP") # raise UserSkipped |
add_dataset = self.Parent.AddDatasetWizard(self.Parent, -1, 'Add Dataset') | add_dataset = AddDatasetWizard(self.Parent, -1, 'Add Dataset') | def AddDataset(self, evt): add_dataset = self.Parent.AddDatasetWizard(self.Parent, -1, 'Add Dataset') if add_dataset.RunWizard(add_dataset.page[0]): dataset_url = add_dataset.url.GetValue() dbname = add_dataset.dbname.GetValue() tablename = add_dataset.tablename.GetValue() fullname = dbname if tablename: fullname += ".... |
class AddDatasetWizard(wx.wizard.Wizard): def __init__(self, parent, id, title): wx.wizard.Wizard.__init__(self, parent, id, title) self.page = [] self.page.append(parent.TitledPage(self, "Add Dataset", "")) hbox = wx.FlexGridSizer(rows=3, cols=2) | class AddDatasetWizard(wx.wizard.Wizard): def __init__(self, parent, id, title): wx.wizard.Wizard.__init__(self, parent, id, title) self.page = [] self.page.append(self.AddDatasetPage(self, "Add Dataset", "")) self.FitToPage(self.page[0]) class AddDatasetPage(DbTkWizard.TitledPage): def __init__(self, parent, title, ... | def CheckValues(self, evt): """Users can't continue from this page without checking at least one dataset.""" if len(self.scriptlist.GetCheckedStrings()) == 0 and evt.Direction: evt.Veto() elif evt.Direction: checked = self.scriptlist.GetCheckedStrings() warn = [script.name for script in self.Parent.dbtk_list if not scr... |
s = skytools.unquote_literal(s, stdstr = True) | s = skytools.unquote_literal(s, True) | def unquote_any(typ, s): if typ == 'ident': ps = [skytools.unquote_ident(p) for p in s.split('.')] s = '.'.join(ps) elif typ == 'str' or typ == 'dolq': s = skytools.unquote_literal(s, stdstr = True) return s |
def normalize_any(s): if s: c = s[0] if c == "'": s = skytools.unquote_literal(s, stdstr = True) else: s = skytools.unquote_fqident(s) | def normalize_any(typ, s): if typ == 'str': s = skytools.unquote_literal(s, stdstr = True) elif typ == 'ident': s = skytools.unquote_fqident(s) | def normalize_any(s): if s: c = s[0] if c == "'": s = skytools.unquote_literal(s, stdstr = True) else: s = skytools.unquote_fqident(s) return s |
if self.name: params[self.name] = word | self.set_param(word, params) | def get_next(self, typ, word, params): for w in self.tok_list: n = w.get_next(typ, word, params) if n: if self.name: params[self.name] = word return n return None |
if self.name: params[self.name] = word | self.set_param(word, params) | def get_next(self, typ, word, params): if typ not in self.tk_type: return None if self.word and word != self.word: return None if self.name: # and not self.name in params: params[self.name] = word return self.next |
if next and self.name: params[self.name] = normalize_any(word) | if next: self.set_param(word, params) | def get_next(self, typ, word, params): """Allow quoted queue names""" next = DynList.get_next(self, typ, word, params) if next and self.name: params[self.name] = normalize_any(word) return next |
w_londiste_add_table = NewTable(w_done, name = 'table') w_londiste_add_seq = NewSeq(w_done, name = 'seq') w_londiste_remove_table = KnownTable(w_done, name = 'table') w_londiste_remove_seq = KnownSeq(w_done, name = 'seq') | w_table_with2 = Proxy() w_table_with = List( Word('skip_truncate', w_table_with2, name = 'skip_truncate'), Word('expect_sync', w_table_with2, name = 'expect_sync'), WordEQ('tgfmt', Value(w_table_with2, name = 'tgfmt'))) w_table_with2.set_real(List( w_done, Symbol(',', w_table_with))) w_londiste_add_table = Proxy() w... | def get_wlist(self): return [] |
q = "select table_name from londiste.table_info"\ | q = "select londiste.quote_fqname(table_name)"\ " from londiste.table_info"\ | def get_known_table_list(self): if not self.cur_queue: return [] qname = skytools.quote_literal(self.cur_queue) q = "select table_name from londiste.table_info"\ " where queue_name = %s order by 1" % qname return self._ccache('known_table_list', q, 'londiste') |
q = "select seq_name from londiste.seq_info"\ | q = "select londiste.quote_fqname(seq_name)"\ " from londiste.seq_info"\ | def get_known_seq_list(self): if not self.cur_queue: return [] qname = skytools.quote_literal(self.cur_queue) q = "select seq_name from londiste.seq_info"\ " where queue_name = %s order by 1" % qname return self._ccache('known_seq_list', q, 'londiste') |
print 'delims: ', repr(readline.get_completer_delims()) | def main_loop(self): readline.parse_and_bind('tab: complete') readline.set_completer(self.rl_completer_safe) print 'delims: ', repr(readline.get_completer_delims()) # remove " from delims readline.set_completer_delims(" \t\n`~!@#$%^&*()-=+[{]}\\|;:',<>/?") | |
readline.set_completer_delims(" \t\n`~!@ | def main_loop(self): readline.parse_and_bind('tab: complete') readline.set_completer(self.rl_completer_safe) print 'delims: ', repr(readline.get_completer_delims()) # remove " from delims readline.set_completer_delims(" \t\n`~!@#$%^&*()-=+[{]}\\|;:',<>/?") | |
if typ == 'ident': w = normalize_any(w) | w = normalize_any(typ, w) | def find_suggestions_real(self, pfx, params): # find level node = top_level pos = 0 for typ, w, pos in self.sql_words(pfx): if typ == 'ident': w = normalize_any(w) node = node.get_next(typ, w, params) if not node: break |
if node: return (node.get_completions(params), pos) | if xnode: return (xnode.get_completions(params), xpos) | def find_suggestions_real(self, pfx, params): # find level node = top_level pos = 0 for typ, w, pos in self.sql_words(pfx): if typ == 'ident': w = normalize_any(w) node = node.get_next(typ, w, params) if not node: break |
return ([], pos) | return ([], xpos) | def find_suggestions_real(self, pfx, params): # find level node = top_level pos = 0 for typ, w, pos in self.sql_words(pfx): if typ == 'ident': w = normalize_any(w) node = node.get_next(typ, w, params) if not node: break |
if typ == 'ident': w = normalize_any(w) | w = normalize_any(typ, w) | def exec_string(self, ln, eof = False): node = top_level params = {} for typ, w, pos in self.sql_words(ln): if typ == 'ident': w = normalize_any(w) #print repr(typ), repr(w) if typ == 'error': print 'syntax error 1:', repr(ln) return onode = node node = node.get_next(typ, w, params) if not node: print "syntax error 2:"... |
curs.execute(q, [self.cur_queue, params['table']]) res = curs.fetchone() print 'ADD_TABLE:', res[0], res[1] | for tbl in params['tables']: curs.execute(q, [self.cur_queue, tbl]) res = curs.fetchone() print res[0], res[1] print 'ADD_TABLE' | def cmd_londiste_add_table(self, params): """Add table.""" |
curs.execute(q, [self.cur_queue, params['table']]) res = curs.fetchone() print 'REMOVE_TABLE:', res[0], res[1] | for tbl in params['tables']: curs.execute(q, [self.cur_queue, tbl]) res = curs.fetchone() print res[0], res[1] print 'REMOVE_TABLE' | def cmd_londiste_remove_table(self, params): """Remove table.""" |
curs.execute(q, [self.cur_queue, params['seq']]) res = curs.fetchone() print 'ADD_SEQ:', res[0], res[1] | for seq in params['seqs']: curs.execute(q, [self.cur_queue, seq]) res = curs.fetchone() print res[0], res[1] print 'ADD_SEQ' | def cmd_londiste_add_seq(self, params): """Add seq.""" |
curs.execute(q, [self.cur_queue, params['seq']]) res = curs.fetchone() | for seq in params['seqs']: curs.execute(q, [self.cur_queue, seq]) res = curs.fetchone() print res[0], res[1] | def cmd_londiste_remove_seq(self, params): """Remove seq.""" |
help = "kill program immidiately (send SIGTERM)") | help = "kill program immediately (send SIGTERM)") | def init_optparse(self, parser = None): """Initialize a OptionParser() instance that will be used to parse command line arguments. |
starts immidiately. If false, DBScript sleeps for a loop_delay. | starts immediately. If false, DBScript sleeps for a loop_delay. | def work(self): """Here should user's processing happen. |
elif ev.type == "TRUNCATE": | elif ev.type == "R": | def process_remote_event(self, src_curs, dst_curs, ev): """handle one event""" self.log.debug("New event: id=%s / type=%s / data=%s / extra1=%s" % (ev.id, ev.type, ev.data, ev.extra1)) if ev.type in ('I', 'U', 'D'): self.handle_data_event(ev, dst_curs) elif ev.type[:2] in ('I:', 'U:', 'D:'): self.handle_data_event(ev, ... |
if ev.type not in ('I', 'U', 'D'): | if ev.type not in ('I', 'U', 'D', 'R'): | def interesting(self, ev): """See if event is interesting.""" if ev.type not in ('I', 'U', 'D'): raise Exception('bug - bad event type in .interesting') t = self.get_table_by_name(ev.extra1) if not t: return 0 if not t.interesting(ev, self.cur_tick, self.copy_thread): return 0 return 1 |
pass | dst_db.commit() | def do_repair(self, src_db, dst_db, where, pfx = 'repair', apply_fixes = False): """Actual comparision.""" |
curs.copy_expert(f, copy_cmd) | curs.copy_expert(copy_cmd, f) | def dump_table(self, copy_cmd, curs, fn): """Dump table to disk.""" f = open(fn, "w", 64*1024) curs.copy_expert(f, copy_cmd) self.log.info('%s: Got %d bytes' % (self.table_name, f.tell())) f.close() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.