text stringlengths 0 828 |
|---|
"""""" |
Instantiates the .datatable attribute, pointing to a table in the |
database that stores all the cached data |
"""""" |
try: |
self.datatable = Table(self.name, Base.metadata, autoload=True) |
except NoSuchTableError: |
print ""Creating datatable, cause it doesn't exist"" |
self.datatable = self._datatable_factory() |
self.datatable.create() |
self.datatable_exists = True" |
1874,"def _datatable_factory(self): |
"""""" |
creates a SQLAlchemy Table object with the appropriate number of |
columns given the number of feeds |
"""""" |
feed_cols = ['feed{0:03d}'.format(i + 1) for i in range(self.n_feeds)] |
feed_cols = ['override_feed000'] + feed_cols + ['failsafe_feed999'] |
ind_sqlatyp = indexingtypes[self.index.indimp].sqlatyp |
dat_sqlatyp = datadefs[self.dtype.datadef].sqlatyp |
atbl = Table(self.name, Base.metadata, |
Column('indx', ind_sqlatyp, primary_key=True), |
Column('final', dat_sqlatyp), |
*(Column(fed_col, dat_sqlatyp) for fed_col in feed_cols), |
extend_existing=True) |
self.dt_feed_cols = feed_cols[:] |
self.dt_all_cols = ['indx', 'final'] + feed_cols[:] |
return atbl" |
1875,"def update_handle(self, chkpnt_settings): |
"""""" |
Update a feeds's handle checkpoint settings |
:param chkpnt_settings, dict: |
a dictionary where the keys are stings representing |
individual handle checkpoint names, for a Feed |
(eg. api_failure, feed_type, monounique...) |
See FeedHandle.__table__.columns for the |
current list. |
The values can be either integer or BitFlags. |
:return: None |
"""""" |
# Note, for now, this function is nearly identical |
# to the Symbol version. Careful when augmenting, |
# to get the right one. |
objs = object_session(self) |
# override with anything passed in |
for checkpoint in chkpnt_settings: |
if checkpoint in FeedHandle.__table__.columns: |
settings = chkpnt_settings[checkpoint] |
setattr(self.handle, checkpoint, settings) |
objs.commit()" |
1876,"def add_tags(self, tags): |
"""""" add a tag or tags to a Feed """""" |
if isinstance(tags, (str, unicode)): |
tags = [tags] |
objs = object_session(self) |
tmps = [FeedTag(tag=t, feed=self) for t in tags] |
objs.add_all(tmps) |
objs.commit()" |
1877,"def initiate_browser(self): |
# Create a unique tempdir for downloaded files |
tempdir = os.getenv(TEMPDIR_ENVVAR, DEFAULT_TEMPDIR) |
tempsubdir = uuid4().hex |
# TODO: Remove this directory when finished! |
self.tempdir = os.path.join(tempdir, tempsubdir) |
try: |
# Try and create directory before checking if it exists, |
# to avoid race condition |
os.makedirs(self.tempdir) |
except OSError: |
if not os.path.isdir(self.tempdir): |
raise |
profile = webdriver.FirefoxProfile() |
# Set download location, avoid download dialogues if possible |
# Different settings needed for different Firefox versions |
# This will be a long list... |
profile.set_preference('browser.download.folderList', 2) |
profile.set_preference('browser.download.manager.showWhenStarting', False) |
profile.set_preference('browser.download.manager.closeWhenDone', True) |
profile.set_preference('browser.download.dir', self.tempdir) |
profile.set_preference(""browser.helperApps.neverAsk.saveToDisk"", ""application/octet-stream;application/vnd.ms-excel"") |
profile.set_preference(""browser.helperApps.alwaysAsk.force"", False) |
profile.set_preference(""browser.download.manager.useWindow"", False) |
self.browser = webdriver.Firefox(profile) |
self.browser.get('http://webbstat.av.se') |
detailed_cls = ""Document_TX_GOTOTAB_Avancerad"" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.