self.hostname=hostname
self.key=key
+ def is_local(self):
+ return utils.is_local (self.hostname)
+
def run (self,command):
- if self.hostname == "localhost":
+ if self.is_local():
return utils.system(command)
else:
if self.key:
return utils.system(to_run)
def copy (self,local_file):
- if self.hostname == "localhost":
+ if self.is_local():
return 0
else:
if self.key:
result +=char
return result
+# check main IP address against the provided hostname
+def is_local (hostname):
+ if hostname == "localhost":
+ return True
+ import socket
+ local_ip = socket.gethostbyname(socket.gethostname())
+ remote_ip = socket.gethostbyname(hostname)
+ return local_ip==remote_ip