Commit dd9ed14c by Bach Dániel

fix mount_store

parent 05b2e754
......@@ -41,12 +41,6 @@ mount_template_linux = (
'//%(host)s/%(username)s %(dir)s cifs username=%(username)s'
',password=%(password)s,iocharset=utf8,uid=cloud 0 0\n')
mount_template_windows = (
'net use * /delete /yes\r\n'
'timeout 5\r\n'
'net use z: \\%(host)s\\%(username)s "%(password)s" '
'/user:%(username)s\r\n')
system = platform.system()
distros = {'Scientific Linux': 'rhel',
......@@ -171,9 +165,11 @@ class Context(object):
subprocess.call('mount -a', shell=True)
elif system == 'Windows':
with open(r'c:\Windows\System32\Repl\Import\Scripts\%s.bat'
% username, 'w') as f:
f.write(mount_template_windows % data)
import notify
url = 'cifs://%s:%s@%s/%s' % (username, password, host, username)
for c in notify.clients:
logger.debug("sending url %s to client %s", url, unicode(c))
c.sendLine(url.encode())
@staticmethod
def get_keys():
......
......@@ -14,6 +14,7 @@ import os
import platform
import subprocess
import urllib2
from urlparse import urlsplit
logger = logging.getLogger()
logger.debug("notify imported")
......@@ -127,6 +128,15 @@ def open_in_browser(url):
webbrowser.open(url, new=2, autoraise=True)
def mount_smb(url):
data = urlsplit(url)
share = data.path.lstrip('/')
subprocess.call(('net', 'use', 'Z:', '/delete'))
subprocess.check_output((
'net', 'use', 'Z:', r'\\%s\%s' % (data.hostname, share),
data.password, '/user:%s' % data.username, '/PERSISTENT:YES'))
def file_already_exists(name, mode=0o644):
"""Return whether file already exists, create it if not.
......@@ -201,7 +211,10 @@ if win:
def lineReceived(self, line):
print "received", line
open_in_browser(line)
if line.startswith('cifs://'):
mount_smb(line)
else:
open_in_browser(line)
class SubFactory(protocol.ReconnectingClientFactory):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment