Не забудьте вставить свои Имя сервера, сетевое имя и пароль. И в тексте профиля в строке password указать свой пароль VNC
Код: Выделить всё
# "pip install smbprotocol" -- https://pypi.org/project/smbprotocol/
import glob
import os
import smbclient
import platform
if platform.system() != 'Linux':
print("Only Linux!!!")
exit()
smbclient.ClientConfig(username='SAMBA_username', password='password')
WTWpath = r"\\srvWTWARE.domain\wtware\Terminals"
remmina_dir = os.path.expanduser(os.path.join("~", ".local/share/remmina"))
WTWpar = ['iswtware', 'ip', 'comment', 'version', 'platform']
listWTW = []
terminals = smbclient.listdir(WTWpath)
for t in terminals:
a = []
for file in WTWpar:
if not smbclient.path.exists(WTWpath + "\\" + t + "\\" + "\iswtware"):
continue
if not smbclient.path.exists(WTWpath + "\\" + t + "\\" + "\ip"):
continue
if file == "comment":
enc = "utf-16le"
else:
enc = "utf8"
with smbclient.open_file((WTWpath + "\\" + t + "\\" + file), mode="r", encoding=enc, errors='ignore') as fd:
a.append(fd.read())
if a:
listWTW.append(a)
for f in glob.glob(remmina_dir + "//wtware_vnc*.remmina"):
os.remove(f)
for itemWTW in listWTW:
if itemWTW[0] == '1':
with open(os.path.join(remmina_dir, "wtware_vnc_{0}_{1}.remmina".format(itemWTW[2], itemWTW[1])), 'w') as f:
f.writelines('''[remmina]
encodings=
username=
name={0}
ssh_tunnel_passphrase=
password=8pfttfdGG4=
quality=2
disablesmoothscrolling=0
precommand=
ssh_tunnel_privatekey=
ssh_tunnel_enabled=0
viewonly=0
ignore-tls-errors=1
disableserverinput=0
postcommand=
tightencoding=0
server={1}
disablepasswordstoring=0
ssh_tunnel_username=
disableclipboard=0
disableserverbell=0
ssh_tunnel_password=
enable-autostart=0
proxy=
ssh_tunnel_server=
disableencryption=0
window_height=480
ssh_tunnel_auth=0
ssh_tunnel_loopback=0
notes_text=
group=WTWare
profile-lock=0
window_width=640
keymap=
colordepth=32
window_maximize=1
protocol=VNC
ssh_tunnel_certfile=
showcursor=0
viewmode=1'''.format(itemWTW[2], itemWTW[1]))
f.close()