-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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=''): |
There was a problem hiding this comment.
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 = [] |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
No description provided.