Skip to content

Commit

Permalink
Add print statements to command
Browse files Browse the repository at this point in the history
Signed-off-by: Jono Yang <jyang@nexb.com>
  • Loading branch information
JonoYang committed Jun 23, 2023
1 parent 2714c9c commit 7a32896
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion packagedb/management/commands/create_source_repo_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ def get_rows(workbook, sheet_name):
source_namespace = row[inventory_column_indices['source_namespace']].value
source_name = row[inventory_column_indices['source_name']].value
source_version = row[inventory_column_indices['source_version']].value
source_purl = row[inventory_column_indices['source_purl']].value
reportable = {
'purl': purl,
'source_download_url': source_download_url,
'source_type': source_type,
'source_namespace': source_namespace,
'source_name': source_name,
'source_version': source_version,
'source_purl': source_purl,
}
rows.append(reportable)
return rows
Expand All @@ -71,6 +73,9 @@ def handle(self, *args, **options):
for row in rows:
# Look up the package the row is for by using the purl to query the db.
purl = row['purl']
source_purl = row['source_purl']
print(f'Processing packages for: {purl}')

lookups = purl_to_lookups(purl)
packages = Package.objects.filter(**lookups)

Expand All @@ -79,13 +84,15 @@ def handle(self, *args, **options):
binary_package = packages.get(qualifiers='')

package_set = binary_package.package_set
if not package_set.package_set:
if not binary_package.package_set:
# Create a new UUID and set it as this set of packages package_set value
package_set = uuid4()
print(f'Set package_set for {binary_package.purl} to {package_set}')

# Set package_content value for binary_package, if needed
if not binary_package.package_content:
binary_package.package_content = PackageContentType.BINARY
print(f'Set package_content for {binary_package.purl} to BINARY')

# Get the source package
# We use .get(qualifiers__contains='classifier=sources') as source JARs have the qualifiers set
Expand All @@ -94,10 +101,12 @@ def handle(self, *args, **options):
# Set the package_set value to be the same as the one used for binary_package, if needed
if not source_package.package_set:
source_package.package_set = package_set
print(f'Set package_set for {source_package.purl} to {package_set}')

# Set source_package value for binary_package, if needed
if not source_package.package_content:
source_package.package_content = PackageContentType.SOURCE_REPO
print(f'Set package_content for {source_package.purl} to SOURCE_REPO')

# Create new Package from the source_ fields
package = Package.objects.create(
Expand All @@ -112,3 +121,4 @@ def handle(self, *args, **options):
)
if package:
add_package_to_scan_queue(package)
print(f'Created source repo package {source_purl} for {purl}')
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ install_requires =
rubymarshal == 1.0.3
scancode-toolkit[full] == 32.0.1
urlpy == 0.5
matchcode-toolkit == 1.0.0
matchcode-toolkit == 1.1.0
setup_requires = setuptools_scm[toml] >= 4

python_requires = >=3.8
Expand Down

0 comments on commit 7a32896

Please sign in to comment.