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

Add radar_sync.py script. #43

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

mgaggero
Copy link

No description provided.

Copy link
Contributor

@simleo simleo left a comment

Choose a reason for hiding this comment

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

More changes proposed in mgaggero#1

self._client = paramiko.SSHClient()
self._root_dir = root_dir

def list_folder(self, year='', month='', day=''):
Copy link
Contributor

Choose a reason for hiding this comment

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

This method has a lot in common with the next one. Perhaps they can be refactored to call a common __exec_command method that does the repetitive job

_folder = '{}/{}/{}/{}'.format(self._root_dir, year, month, day)

_, stdout, _ = self._client.exec_command('ls {}'.format(_folder))
_contents = []
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be moved out of the try block, or exception will also trigger an UnboundLocalError: local variable '_contents' referenced before assignment

key_filename=self._key_file
)

_folder = '{}/{}/{}/{}'.format(self._root_dir, year, month, day)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a job for os.path.join

_transport.close()


def check_hdfs_url(hdfs_url):
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not necessary and potentially harmful. Better let the user's path through and let Pydoop / Hadoop handle it

if not args.dryrun:
copy_to_hdfs(_local_path, _hdfs_path)

delete_local_folder(_local_path, args.dryrun)
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like we can just use shutil.rmtree here, and get rid of delete_local_folder

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