Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def process(self):
if self.os and self.kernel and self.arch:
os, c = OS.objects.get_or_create(name=self.os)
arch, c = MachineArchitecture.objects.get_or_create(name=self.arch)
if not self.domain:
self.domain = 'unknown'
domain, c = Domain.objects.get_or_create(name=self.domain)
if not self.host:
try:
self.host = str(gethostbyaddr(self.report_ip)[0])
except:
self.host = self.report_ip
host, c = Host.objects.get_or_create(
hostname=self.host,
defaults={
'ipaddress': self.report_ip,
"""
parches = PackageArchitecture.objects.filter(package__isnull=True)
plen = parches.count()
if plen == 0:
if verbose:
print 'No orphaned package architectures found.'
else:
create_pbar('Removing {0!s} orphaned p arches:'.format(plen), plen)
for i, p in enumerate(parches):
a = PackageArchitecture.objects.get(name=p.name)
a.delete()
update_pbar(i + 1)
marches = MachineArchitecture.objects.filter(host__isnull=True,
repository__isnull=True)
mlen = marches.count()
if mlen == 0:
if verbose:
print 'No orphaned machine architectures found.'
else:
create_pbar('Removing {0!s} orphaned m arches:'.format(mlen), mlen)
for i, m in enumerate(marches):
a = MachineArchitecture.objects.get(name=m.name)
a.delete()
update_pbar(i + 1)
def import_arch(conn):
cursor = conn.cursor(MySQLdb.cursors.DictCursor)
cursor.execute('SELECT * FROM arch')
rows = cursor.fetchall()
plength = len(rows)
pbar = progress_bar('Machine Architectures', plength)
i = 0
for row in rows:
pbar.update(i+1)
i += 1
try:
arch, c = MachineArchitecture.objects.get_or_create(id=row['id'], name=row['arch'])
except(IntegrityError):
print "IntegrityError"
continue
cursor.close()
cursor = conn.cursor(MySQLdb.cursors.DictCursor)
cursor.execute('SELECT DISTINCT arch FROM act_version')
rows = cursor.fetchall()
plength = len(rows)
pbar = progress_bar('Package Architectures', plength)
i = 0
for row in rows: