Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor github backup script #63

Merged

Conversation

alneberg
Copy link
Member

Ended up rewriting most of the code. It's now:

  • Running on python 3
  • Using a more maintained pygithub implementation
  • Fulfilling pep8 (mostly)
  • Logging nicely to both file and stream
  • Accepting parameters for organizations and final destination

@alneberg alneberg requested review from ewels and ssjunnebo November 26, 2019 15:54
Copy link
Contributor

@ssjunnebo ssjunnebo left a comment

Choose a reason for hiding this comment

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

Looks great! Just a couple of comments, mostly style related so feel free to ignore those. +1 for pep8! 😃

backup_github.py Outdated
gh = Github(user, password)
repos_l = [] # list of repos iterators
for org in organizations:
gh_org = gh.get_organization(org)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to be picky, maybe consider renaming some variables here? 😉 Perhaps github_instance instead of gh, repositories instead of repos_l, organization instead of org, and github_organization instead of gh_org, or something similar?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I might have some personal abbreviations which I don't realise are not common to everyone

backup_github.py Outdated
except CalledProcessError as e:
logger.error("ERROR: Error cloning repository {}, "
"skipping it".format(repo.name))
logger.error(str(e))
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be indented one more time? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it can be deleted - doesn't look like it is doing anything to me..

Copy link
Member Author

Choose a reason for hiding this comment

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

Very good catch!

Copy link
Member Author

Choose a reason for hiding this comment

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

@ewels, true. except-pass doesn't do anything else than the default for just except right?

Copy link
Contributor

Choose a reason for hiding this comment

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

It’s not even that. pass does literally nothing, but you need something after except to avoid an indentation error. So if you have any code there at all it’s not necessary (eg. a log message)

Copy link
Contributor

Choose a reason for hiding this comment

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

It’s not even that

I mean, it’s not a default (assuming that a default usually does something)

backup_github.py Outdated
pass

def compressAndMove(source):

def compressAndMove(source, final_dest):
Copy link
Contributor

Choose a reason for hiding this comment

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

For pep8: function names should be lowercase, with words separated by underscores

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed!

@ssjunnebo ssjunnebo merged commit 15da87e into NationalGenomicsInfrastructure:master Nov 27, 2019
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.

3 participants