Colin Copeland avatar Colin Copeland committed b95b371

add sudo support fixes #3

Comments (0)

Files changed (2)

         return p
     def remote(self, cmd, **kwargs):
-        args = {'host':, 'cmd': cmd}
-        ssh = 'ssh -C %(host)s %(cmd)s' % args
-        return self.execute(ssh, **kwargs)
+        if self.sudo_user:
+            cmd = self.sudo(cmd)
+        remote_cmd = ['ssh -C',, cmd]
+        return self.execute(' '.join(remote_cmd), **kwargs)
     def sudo(self, cmd):
-        args = {'cmd': cmd}
+        sudo_cmd = ['sudo']
         if self.sudo_user:
-            args['user'] = ' -u %(user)s '.format({'user': self.sudo_user})
-        else:
-            args = {'user': ''}
-        return 'sudo %(user)s %(cmd)s'.format(args)
+            sudo_cmd.append('-u %s' % self.sudo_user)
+        sudo_cmd.append(cmd)
+        return ' '.join(sudo_cmd)
     def chmod(self, path):
         os.chmod(path, self.fmod)


         data = {'host': host}
         if cfg.has_option(host, 'user'):
             data['host'] = '%s@%s' % (cfg.get(host, 'user'), host)
+        if cfg.has_option(host, 'sudo_user'):
+            data['sudo_user'] = cfg.get(host, 'sudo_user')
         if cfg.has_option(host, 'postgres'):
             databases = cfg.get(host, 'postgres').strip()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.