text
stringlengths
0
828
raise
else:
self.commit()
for row in converted_data:
self.__check_and_add_columns(table_name, row)"
1287,"def get_var(self, key):
'Retrieve one saved variable from the database.'
vt = quote(self.__vars_table)
data = self.execute(u'SELECT * FROM %s WHERE `key` = ?' % vt, [key], commit = False)
if data == []:
raise NameError(u'The DumpTruck variables table doesn\'t have a value for %s.' % key)
else:
tmp = quote(self.__vars_table_tmp)
row = data[0]
self.execute(u'DROP TABLE IF EXISTS %s' % tmp, commit = False)
# This is vulnerable to injection
self.execute(u'CREATE TEMPORARY TABLE %s (`value` %s)' % (tmp, row['type']), commit = False)
# This is ugly
self.execute(u'INSERT INTO %s (`value`) VALUES (?)' % tmp, [row['value']], commit = False)
value = self.dump(tmp)[0]['value']
self.execute(u'DROP TABLE %s' % tmp, commit = False)
return value"
1288,"def save_var(self, key, value, **kwargs):
'Save one variable to the database.'
# Check whether Highwall's variables table exists
self.__check_or_create_vars_table()
column_type = get_column_type(value)
tmp = quote(self.__vars_table_tmp)
self.execute(u'DROP TABLE IF EXISTS %s' % tmp, commit = False)
# This is vulnerable to injection
self.execute(u'CREATE TABLE %s (`value` %s)' % (tmp, column_type), commit = False)
# This is ugly
self.execute(u'INSERT INTO %s (`value`) VALUES (?)' % tmp, [value], commit = False)
table = (quote(self.__vars_table), tmp)
params = [key, column_type]
self.execute(u'''
INSERT OR REPLACE INTO %s (`key`, `type`, `value`)
SELECT
? AS key,
? AS type,
value
FROM %s
''' % table, params)
self.execute(u'DROP TABLE %s' % tmp, commit = False)
self.__commit_if_necessary(kwargs)"
1289,"def tablesAndViews(self):
""""""Return a sequence of (name,type) pairs where type is
either ""table"" or ""view"".""""""
result = self.execute(
u'SELECT name,type FROM sqlite_master WHERE type in (""table"", ""view"")',
commit=False)
return ((row['name'],row['type']) for row in result)"
1290,"def drop(self, table_name = 'dumptruck', if_exists = False, **kwargs):
'Drop a table.'
return self.execute(u'DROP TABLE %s %s;' % ('IF EXISTS' if if_exists else '', quote(table_name)), **kwargs)"
1291,"def __install_perforce(self, config):
"""""" install perforce binary """"""
if not system.is_64_bit():
self.logger.warn(""Perforce formula is only designed for 64 bit systems! Not install executables..."")
return False
version = config.get('version', 'r13.2')
key = 'osx' if system.is_osx() else 'linux'
perforce_packages = package_dict[version][key]
d = self.directory.install_directory(self.feature_name)
if not os.path.exists(d):
os.makedirs(d)
self.logger.info(""Downloading p4 executable..."")
with open(os.path.join(d, ""p4""), 'wb+') as fh:
fh.write(lib.cleaned_request('get', url_prefix + perforce_packages['p4']).content)
self.directory.symlink_to_bin(""p4"", os.path.join(d, ""p4""))
self.p4_command = os.path.join(d, ""p4"")
self.logger.info(""Installing p4v..."")
if system.is_osx():
return self._install_p4v_osx(url_prefix + perforce_packages['p4v'])
else:
return self._install_p4v_linux(url_prefix + perforce_packages['p4v'])"
1292,"def _install_p4v_osx(self, url, overwrite=False):
"""""" Install perforce applications and binaries for mac """"""
package_exists = False
root_dir = os.path.expanduser(os.path.join(""~"", ""Applications""))
package_exists = len([x for x in P4V_APPLICATIONS if os.path.exists(os.path.join(root_dir, x))])
if not package_exists or overwrite:
lib.extract_dmg(url, root_dir)
else:
self.logger.warn(""P4V exists already in %s! Not overwriting..."" % root_dir)
return True"
1293,"def _install_p4v_linux(self, url):
"""""" Install perforce applications and binaries for linux """"""
lib.extract_targz(url,