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

Adding logging #6

Merged
merged 1 commit into from
Oct 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions pydfs/client.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import rpyc
import sys
import os
import logging

logging.basicConfig(level=logging.DEBUG)
LOG = logging.getLogger(__name__)

def send_to_minion(block_uuid,data,minions):
print "sending: " + str(block_uuid) + str(minions)
LOG.info("sending: " + str(block_uuid) + str(minions))
minion=minions[0]
minions=minions[1:]
host,port=minion
Expand All @@ -22,7 +26,7 @@ def read_from_minion(block_uuid,minion):
def get(master,fname):
file_table = master.get_file_table_entry(fname)
if not file_table:
print "404: file not found"
LOG.info("404: file not found")
return

for block in file_table:
Expand All @@ -32,7 +36,7 @@ def get(master,fname):
sys.stdout.write(data)
break
else:
print "No blocks found. Possibly a corrupt file"
LOG.info("No blocks found. Possibly a corrupt file")

def put(master,source,dest):
size = os.path.getsize(source)
Expand All @@ -54,8 +58,8 @@ def main(args):
elif args[0] == "put":
put(master,args[1],args[2])
else:
print "try 'put srcFile destFile OR get file'"
LOG.error("try 'put srcFile destFile OR get file'")


if __name__ == "__main__":
main(sys.argv[1:])
main(sys.argv[1:])