Skip to content

Use output of rpm --eval command, in case import of rpm module fails#139

Merged
mcyprian merged 2 commits intomasterfrom
save-dir-value
Sep 26, 2017
Merged

Use output of rpm --eval command, in case import of rpm module fails#139
mcyprian merged 2 commits intomasterfrom
save-dir-value

Conversation

@mcyprian
Copy link
Copy Markdown
Member

Order of the methods to get DEFAULT_PKG_SAVE_PATH is following:

  • rpm Python API (should work on systems where is yum/dnf installed)
  • rpm --eval command
  • hardcoded path ~/rpmbuild (nonrpm environments e.g. travis)

Some functions from utils had to be moved elsewhere to prevent circular dependency between utils and settings modules.

Redesign utils module to prevent circular dependency

Resolves #117
Copy link
Copy Markdown
Contributor

@irushchyshyn irushchyshyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.
I believe if those functions are used only in metadata_extractors.py then they should not have been in utils in the first place, so moving them there is fine and fixes circular dependency issue. But we'll never be able to use settings in utils, oh well:)

How about adding some tests for get_default_save_path and rpm_eval?

Comment thread pyp2rpm/metadata_extractors.py Outdated
"""
license = []
for classifier in trove:
if 'License' in classifier != -1:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe != -1 part is redundant?

Comment thread pyp2rpm/utils.py
['rpm', '--eval', macro],
stdout=subprocess.PIPE).communicate()[0].strip()
except OSError:
logger.error('Failed to get value of {0} rpm macro'.format(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be warning for the user, also saying that the default path will be used.

Copy link
Copy Markdown
Contributor

@irushchyshyn irushchyshyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes. Looks good.
Please squash the fixup and merge at will.

@mcyprian mcyprian merged commit 1b3bab8 into master Sep 26, 2017
@irushchyshyn irushchyshyn deleted the save-dir-value branch September 26, 2017 12:03
mcyprian pushed a commit that referenced this pull request Oct 10, 2017
…139)

* Use output of rpm --eval command, in case import of rpm module fails

Redesign utils module to prevent circular dependency

Resolves #117
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants