Page 2 of 2
Re: Mblock Setup.py
Published: Dec 29, 2017 - 12:31
by sfonteneau
Code: Select all
sfonteneau, pour éviter de perdre du temps et faire ça bien, peux-tu nous aider dans la rédaction du session_setup STP?
If you have a method that works every time, yes, I can..

But for now it's a bit unclear
The simplest solution in this case would be to contact a developer:
http://www.mblock.cc/contactus/
Ultimately, in my opinion, it will end up with the software detecting the system language upon first startup

and set this language as the default at startup.
I have already contacted some application developers about this kind of thing and they can be quite receptive.
Up to you !
Re: Mblock Setup.py
Published: Dec 29, 2017 - 2:34 PM
by myosotis
This involves copying a /com.makeblock.Scratch3.4.11/Local Store file "formatted" in French into the AppData/Roming/ directory of each user
, and also ensuring that it works for the interactive or current user as well, in French...
Re: Mblock Setup.py
Published: Dec 29, 2017 - 5:18 PM
by sfonteneau
myosotis wrote: ↑Dec 29, 2017 - 2:34 PM
It involves copying a /com.makeblock.Scratch3.4.11/Local Store file "formatted" in French into the AppData/Roming/ directory of each user
and also ensuring that it works for the interactive or current user as well, in French...
For the part:
myosotis wrote: ↑Dec 29, 2017 - 2:34 PM
Also make sure that it works for interactive or current user as well, in French
I don't quite understand.
On the other hand, you can indeed create a working com.makeblock.Scratch3.4.11, copy it during the def install() into a folder on the machine and then copy it in reverse during the session_setup into the user's %appdata%.
The next question is what to do if the com.makeblock.Scratch3.4.11 folder already exists during session setup. Do we overwrite it, even if the user has already configured their settings? Or do we just overwrite it?
https://dev.tranquil.it/sphinxdocs/sour....copytree2
Re: Mblock Setup.py
Published: Dec 29, 2017 - 6:12 PM
by myosotis
I'll try to copy my code for you as soon as possible. Thank you so much for your help.
I did try using copytree2. It works on a path that isn't relative to the user (I'm doing this as a prerequisite since a session setup() prevents accessing a file or folder provided in the package; so I copy "my source code" from the package into a folder in ProgramData and then try to access it... without success so far).
Overwriting the personal folder in AppData is not an option. In our production environment, the user isn't encouraged to save anything locally.
Rereading your message, I get the impression that the focus shouldn't be on the user, but on AppData. Perhaps that's where I'm going wrong...?!!
Re: Mblock Setup.py
Published: Dec 31, 2017 - 4:06 PM
by myosotis
Code: Select all
# -*- coding: utf-8 -*-
from setuphelpers import *
# Importation des fichiers de personalisation
copytree2(r'Perso',r'C:\ProgramData\mBlock') #Import du dossier fourni dans le paquet
filecopyto(r'Copy.cmd',r'C:\ProgramData\mBlock') #Import d'un fourni egalement avec le paquet
key = "{1E9DFEBB-4088-4693-A521-C755318BD492}_is1"
uninstallkey = ['{1E9DFEBB-4088-4693-A521-C755318BD492}_is1']
#Creation d'un targetdir en faisant usage de user_appdata qui selon la doc renvoit à /userX/appdata/roaming/
targetdir = makepath(user_appdata(),'com.makeblock.Scratch3.4.11')
print targetdir # ça c'est pour moi ;) - ca m'affiche bien le dossier souhaité... malheureusement l'exploit est nulle
#uninstallstring = [r' ""C:\Program Files (x86)\mBlock\unins000.exe" /SILENT {1E9DFEBB-4088-4693-A521-C755318BD492}_is1']
def install():
versionpaquet = control['version'].split('-',1)[0]
print('Importation de drivers')
with disable_file_system_redirection():
run('regedit.exe /s usbserial_arduino.reg')
run(r'"%s" /VERYSILENT' % makepath('drivers','Driver_for_Windows.exe'))
print('Installation de util-mblock')
install_exe_if_needed("mBlock_win_V"+versionpaquet+".exe",
silentflags="/VERYSILENT",
key=key,
min_version=versionpaquet,
killbefore="mBlock.exe")
#suppression de la clé de désinstallation pour pouvoir faire une désinstallation silencieuse. Voir def uninstall():
#uninstallkey.remove(key) # FONCTION pas dispo dans Setuphelpers v1.3.5
#suppression du raccourci bureau
#remove_desktop_shortcut('mBlock')
print "Post installation"
lang = makepath(targetdir)
if not isdir(lang):
os.makedirs(lang)
copytree2('Perso','targetdir') #Tentative d'import de com.makeblock.Scratch3.4.11 via fonction copytree2 + user_appdata() : Resultat non probant
session_setup()
def uninstall():
print('Désinstallation de util-mblock')
run(r'"%s\unins000.exe" /VERYSILENT' % install_location(key))
def session_setup():
targetdir = makepath(user_appdata(),'com.makeblock.Scratch3.4.11')
if not isdir(targetdir):
print('creation du dossier com.makeblock.Scratch3.4.11')
mkdirs(makepath(user_appdata(),'com.makeblock.Scratch3.4.11'))
#copytree2('C:\ProgramData\mBlock','targetdir')
run(r'C:\ProgramData\mBlock\Copy.cmd')
#ci-dessus vs avez mes 2 tentatives : (1) via copytree2;, l'autre via le run d'un cmd que j'ai essayé de runner pour injecter les fichiers adéquats. Ni l'une, ni l'autre des méthodes ne fonctionnent.
else:
#remove_file(makepath(user_appdata(),'com.makeblock.Scratch3.4.11'))
#copytree2('C:\ProgramData\mBlock','targetdir')
run(r'C:\ProgramData\mBlock\Copy.cmd')
#copytree2(r'C:\ProgramData\mBlock',r'%USERPROFILE%\AppData\Roaming')
#Personalisation de mblock pour l'interactive User - Alternative try
run(r'"Copy.cmd"')
+ Copy of my cmd
Code: Select all
if not exist C:\Users\%username%\AppData\Roaming\com.makeblock.Scratch3.4.11 mkdir C:\Users\%username%\AppData\Roaming\com.makeblock.Scratch3.4.11
xcopy C:\ProgramData\mBlock\com.makeblock.Scratch3.4.11 C:\Users\%username%\AppData\Roaming\com.makeblock.Scratch3.4.11 /E /C /Y
...it doesn't work...no more than with %appdata%
:'( .... can't we interact with the current user's appdata while a package is being deployed?
Re: Mblock Setup.py
Published: Dec 31, 2017 - 6:15 PM
by sfonteneau
myosotis wrote: ↑Dec 31, 2017 - 4:06 PM
Can't we interact with the current user's appdata while a package is being deployed?
It's possible, but it's more complicated; session setup makes things simpler:
Code: Select all
# -*- coding: utf-8 -*-
from setuphelpers import *
uninstallkey = []
key = "{1E9DFEBB-4088-4693-A521-C755318BD492}_is1"
profil_name = 'com.makeblock.Scratch3.4.11'
profil_mblock_appdata = makepath('c:','ProgramData','mblock',profil_name)
profil_mblock = makepath(application_data(),profil_name)
def install():
versionpaquet = control['version'].split('-',1)[0]
print('Importation des drivers')
with disable_file_system_redirection():
run('regedit.exe /s usbserial_arduino.reg')
run(r'"%s" /VERYSILENT' % makepath('drivers','Driver_for_Windows.exe'))
print('installing aiz-mblock')
install_exe_if_needed("mBlock_win_V"+versionpaquet+".exe",
silentflags="/VERYSILENT",
key=key,
min_version=versionpaquet,
killbefore="mBlock.exe")
#suppression de la clé de désinstallation pour pouvoir faire une désinstallation silencieuse. Voir def uninstall():
uninstallkey.remove(key)
#suppression du raccourci bureau
remove_desktop_shortcut('mBlock')
if isdir(profil_mblock_appdata):
remove_tree(profil_mblock_appdata)
copytree2(profil_name,profil_mblock_appdata)
def session_setup():
if isdir(profil_mblock):
remove_tree(profil_mblock)
copytree2(profil_mblock_appdata,profil_mblock)
def uninstall():
print('uninstalling aiz-mblock')
run(r'"%s\unins000.exe" /VERYSILENT' % install_location(key))
The profile "com.makeblock.Scratch3.4.11" will be overwritten at the next login.
This way, even if the user profile doesn't exist yet, it will work perfectly!
Don't forget to increment the package version number after each modification to the session setup!
Re: Mblock Setup.py
Published: January 9, 2018 - 4:11 PM
by myosotis
Hello sfonteneau,
after multiple tests and attempts, we still haven't managed to access the appdata of the user who downloads the package; in short, the initial objective hasn't been achieved.
Nevertheless, the proposed mechanism, implemented via session_setup(), works, and therefore, upon reopening the session, the software is in French.
Finally, I suggest a small modification to your excellent script: Modify the profil_mblock_appdata variable. Since it's then used in raw mode, it was necessary to define it as follows: profil_mblock_appdata = makepath('c:\\', 'ProgramData', 'mblock', profil_name).
Best wishes! Thank you for your help. In my opinion, the issue is resolved. Some limitations have been reached.
Re: Mblock Setup.py
Published: January 9, 2018 - 7:20 PM
by sfonteneau
myosotis wrote: ↑January 9, 2018 - 4:11 PM
Finally, I suggest a small modification to your excellent script: Modification of the profil_mblock_appdata variable. Since it is then used in raw format, it was necessary to define it like this: profil_mblock_appdata = makepath('
c:\\','ProgramData','mblock',profil_name)
No problems here, what version of Wapt do you have?
myosotis wrote: ↑Jan 9, 2018 - 4:11 PM
Some limits have been reached.
If you really want to copy this folder during installation, you need to do something like this:
Code: Select all
for locprof in local_users_profiles():
if isdir(makepath(locprof,'AppData','Roaming',profil_name)):
remove_tree(makepath(locprof,'AppData','Roaming',profil_name))
copytree2(profil_name,makepath(locprof,'AppData','Roaming',profil_name))
So, does that mean stopping the mblock that's currently running?