Remove 2-nd process orchestrator add Admin rights def to run Orc before it will be called (because of the CP init before)

dev-linux
Ivan Maslov 4 years ago
parent 33ed3ad95a
commit df357e58ce

@ -1,4 +1,5 @@
cd %~dp0
taskkill /im "pyOpenRPA_Agent.exe" /F /fi "username eq %username%"
copy /Y ..\Resources\WPy64-3720\python-3.7.2.amd64\pythonw.exe ..\Resources\WPy64-3720\python-3.7.2.amd64\pyOpenRPA_Agent.exe
.\..\Resources\WPy64-3720\python-3.7.2.amd64\pyOpenRPA_Agent.exe "AgentSettings.py"
pause >nul

@ -1,4 +1,5 @@
cd %~dp0
taskkill /im "pyOpenRPA_Agent.exe" /F /fi "username eq %username%"
copy /Y ..\Resources\WPy64-3720\python-3.7.2.amd64\python.exe ..\Resources\WPy64-3720\python-3.7.2.amd64\pyOpenRPA_Agent.exe
.\..\Resources\WPy64-3720\python-3.7.2.amd64\pyOpenRPA_Agent.exe "AgentSettings.py"
pause >nul

@ -1,4 +1,4 @@
import psutil, datetime, logging, os, sys # stdout from logging
import psutil, datetime, logging, os, sys, getpass # stdout from logging
# Config settings
lPyOpenRPASourceFolderPathStr = r"..\Sources" # Path for test pyOpenRPA package
@ -7,7 +7,7 @@ lPyOpenRPASourceFolderPathStr = r"..\Sources" # Path for test pyOpenRPA package
if lPyOpenRPASourceFolderPathStr != "": sys.path.insert(0,os.path.abspath(os.path.join(lPyOpenRPASourceFolderPathStr))) # Path for test pyOpenRPA package
from pyOpenRPA.Agent import __Agent__
gUserNameUpperStr = getpass.getuser().upper()
if __name__ == "__main__": # New init way
gSettings = {
"OrchestratorDict":{
@ -46,8 +46,8 @@ if __name__ == "__main__": # New init way
},
}
if not os.path.exists("Reports"):
os.makedirs("Reports")
if not os.path.exists("Logs"):
os.makedirs("Logs")
##########################
# Подготовка логгера Robot
#########################
@ -55,7 +55,7 @@ if __name__ == "__main__": # New init way
lL.setLevel(logging.INFO)
# create the logging file handler
mRobotLoggerFH = logging.FileHandler(
"Reports\\" + datetime.datetime.now().strftime("%Y_%m_%d") + ".log")
"Logs\\" + gUserNameUpperStr + "_" + datetime.datetime.now().strftime("%Y_%m_%d") + ".log")
mRobotLoggerFormatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
mRobotLoggerFH.setFormatter(mRobotLoggerFormatter)
# add handler to logger object

@ -8,9 +8,12 @@ if lPyOpenRPASourceFolderPathStr != "": sys.path.insert(0,os.path.abspath(os.pat
# Start import after config the pyOpenRPA folder
from pyOpenRPA.Orchestrator import SettingsTemplate # Import functionallity
if __name__ == "__main__": # New init way - allow run as module -m PyOpenRPA.Orchestrator
from pyOpenRPA import Orchestrator # Import orchestrator main
#Run as administrator
if not Orchestrator.OrchestratorIsAdmin():
Orchestrator.OrchestratorRerunAsAdmin()
print(f"Orchestrator will be run as administrator!")
elif __name__ == "__main__": # New init way - allow run as module -m PyOpenRPA.Orchestrator
gSettings = SettingsTemplate.Create(inModeStr="BASIC") # Create GSettings with basic configuration - no more config is available from the box - you can create own
# TEST Add User ND - Add Login ND to superuser of the Orchestrator
@ -60,7 +63,6 @@ if __name__ == "__main__": # New init way - allow run as module -m PyOpenRPA.Orc
# Call the orchestrator def
Orchestrator.Orchestrator(inGSettings=gSettings, inDumpRestoreBool=False)
else:
print("!WARNING! Current orchestrator settings do not support old type of the Orchestrator start. Use new Orchestrator type start (see v1.2.0)")

@ -1,3 +1,4 @@
cd %~dp0
taskkill /im "pyOpenRPA_Orchestrator.exe" /F /fi "username eq %username%"
copy /Y ..\Resources\WPy64-3720\python-3.7.2.amd64\python.exe ..\Resources\WPy64-3720\python-3.7.2.amd64\pyOpenRPA_Orchestrator.exe
.\..\Resources\WPy64-3720\python-3.7.2.amd64\pyOpenRPA_Orchestrator.exe "OrchestratorSettings.py"

@ -325,6 +325,29 @@ def OrchestratorRestart(inGSettings=None):
os.execl(sys.executable, os.path.abspath(__file__), *sys.argv)
sys.exit(0)
def OrchestratorIsAdmin():
"""
Check if Orchestrator process is running as administrator
:return: True - run as administrator; False - not as administrator
"""
try:
return ctypes.windll.shell32.IsUserAnAdmin()
except:
return False
def OrchestratorRerunAsAdmin():
"""
Check if not admin - then rerun orchestrator as administrator
:return: True - run as administrator; False - not as administrator
"""
if not OrchestratorIsAdmin():
# Re-run the program with admin rights
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)
else:
print(f"!SKIPPED! Already run as administrator!")
def OrchestratorSessionSave(inGSettings):
"""
Orchestrator session save in file
@ -1878,17 +1901,11 @@ def GSettingsAutocleaner(inGSettings):
from .. import __version__ # Get version from the package
def Orchestrator(inGSettings, inDumpRestoreBool = True):
def Orchestrator(inGSettings, inDumpRestoreBool = True, inRunAsAdministratorBool = True):
lL = inGSettings["Logger"]
# https://stackoverflow.com/questions/130763/request-uac-elevation-from-within-a-python-script
def is_admin():
try:
return ctypes.windll.shell32.IsUserAnAdmin()
except:
return False
if not is_admin():
# Re-run the program with admin rights
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)
if not OrchestratorIsAdmin() and inRunAsAdministratorBool==True:
OrchestratorRerunAsAdmin()
else:
# Code of your program here
#mGlobalDict = Settings.Settings(sys.argv[1])

@ -309,13 +309,19 @@
<tr class="row-odd"><td><p><a class="reference internal" href="#pyOpenRPA.Orchestrator.__Orchestrator__.OSCredentialsVerify" title="pyOpenRPA.Orchestrator.__Orchestrator__.OSCredentialsVerify"><code class="xref py py-obj docutils literal notranslate"><span class="pre">OSCredentialsVerify</span></code></a>(inUserStr, inPasswordStr)</p></td>
<td><p>Verify user credentials in windows.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorIsAdmin" title="pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorIsAdmin"><code class="xref py py-obj docutils literal notranslate"><span class="pre">OrchestratorIsAdmin</span></code></a>()</p></td>
<td><p>Check if Orchestrator process is running as administrator</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorRerunAsAdmin" title="pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorRerunAsAdmin"><code class="xref py py-obj docutils literal notranslate"><span class="pre">OrchestratorRerunAsAdmin</span></code></a>()</p></td>
<td><p>Check if not admin - then rerun orchestrator as administrator</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorRestart" title="pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorRestart"><code class="xref py py-obj docutils literal notranslate"><span class="pre">OrchestratorRestart</span></code></a>([inGSettings])</p></td>
<td><p>Orchestrator restart</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionRestore" title="pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionRestore"><code class="xref py py-obj docutils literal notranslate"><span class="pre">OrchestratorSessionRestore</span></code></a>([inGSettings])</p></td>
<tr class="row-odd"><td><p><a class="reference internal" href="#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionRestore" title="pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionRestore"><code class="xref py py-obj docutils literal notranslate"><span class="pre">OrchestratorSessionRestore</span></code></a>(inGSettings)</p></td>
<td><p>Check _SessionLast_RDPList.json and _SessionLast_StorageDict.pickle in working directory. if exist - load into gsettings # _SessionLast_StorageDict.pickle (binary) _SessionLast_RDPList.json (encoding = “utf-8”) _SessionLast_StorageDict.pickle (binary).</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionSave" title="pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionSave"><code class="xref py py-obj docutils literal notranslate"><span class="pre">OrchestratorSessionSave</span></code></a>([inGSettings])</p></td>
<tr class="row-even"><td><p><a class="reference internal" href="#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionSave" title="pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionSave"><code class="xref py py-obj docutils literal notranslate"><span class="pre">OrchestratorSessionSave</span></code></a>(inGSettings)</p></td>
<td><p>Orchestrator session save in file</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#pyOpenRPA.Orchestrator.__Orchestrator__.ProcessDefIntervalCall" title="pyOpenRPA.Orchestrator.__Orchestrator__.ProcessDefIntervalCall"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ProcessDefIntervalCall</span></code></a>(inGSettings, inDef, …)</p></td>
@ -778,6 +784,28 @@
</dl>
</dd></dl>
<dl class="py function">
<dt id="pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorIsAdmin">
<code class="sig-prename descclassname">pyOpenRPA.Orchestrator.__Orchestrator__.</code><code class="sig-name descname">OrchestratorIsAdmin</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/pyOpenRPA/Orchestrator/__Orchestrator__.html#OrchestratorIsAdmin"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorIsAdmin" title="Permalink to this definition"></a></dt>
<dd><p>Check if Orchestrator process is running as administrator</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>True - run as administrator; False - not as administrator</p>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorRerunAsAdmin">
<code class="sig-prename descclassname">pyOpenRPA.Orchestrator.__Orchestrator__.</code><code class="sig-name descname">OrchestratorRerunAsAdmin</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/pyOpenRPA/Orchestrator/__Orchestrator__.html#OrchestratorRerunAsAdmin"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorRerunAsAdmin" title="Permalink to this definition"></a></dt>
<dd><p>Check if not admin - then rerun orchestrator as administrator</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>True - run as administrator; False - not as administrator</p>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorRestart">
<code class="sig-prename descclassname">pyOpenRPA.Orchestrator.__Orchestrator__.</code><code class="sig-name descname">OrchestratorRestart</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">inGSettings</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/pyOpenRPA/Orchestrator/__Orchestrator__.html#OrchestratorRestart"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorRestart" title="Permalink to this definition"></a></dt>
@ -791,7 +819,7 @@
<dl class="py function">
<dt id="pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionRestore">
<code class="sig-prename descclassname">pyOpenRPA.Orchestrator.__Orchestrator__.</code><code class="sig-name descname">OrchestratorSessionRestore</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">inGSettings</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/pyOpenRPA/Orchestrator/__Orchestrator__.html#OrchestratorSessionRestore"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionRestore" title="Permalink to this definition"></a></dt>
<code class="sig-prename descclassname">pyOpenRPA.Orchestrator.__Orchestrator__.</code><code class="sig-name descname">OrchestratorSessionRestore</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">inGSettings</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/pyOpenRPA/Orchestrator/__Orchestrator__.html#OrchestratorSessionRestore"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionRestore" title="Permalink to this definition"></a></dt>
<dd><p>Check _SessionLast_RDPList.json and _SessionLast_StorageDict.pickle in working directory. if exist - load into gsettings
# _SessionLast_StorageDict.pickle (binary)</p>
<blockquote>
@ -810,7 +838,7 @@ _SessionLast_StorageDict.pickle (binary)</p>
<dl class="py function">
<dt id="pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionSave">
<code class="sig-prename descclassname">pyOpenRPA.Orchestrator.__Orchestrator__.</code><code class="sig-name descname">OrchestratorSessionSave</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">inGSettings</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/pyOpenRPA/Orchestrator/__Orchestrator__.html#OrchestratorSessionSave"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionSave" title="Permalink to this definition"></a></dt>
<code class="sig-prename descclassname">pyOpenRPA.Orchestrator.__Orchestrator__.</code><code class="sig-name descname">OrchestratorSessionSave</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">inGSettings</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/pyOpenRPA/Orchestrator/__Orchestrator__.html#OrchestratorSessionSave"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionSave" title="Permalink to this definition"></a></dt>
<dd><dl class="simple">
<dt>Orchestrator session save in file</dt><dd><p>_SessionLast_RDPList.json (encoding = “utf-8”)
_SessionLast_StorageDict.pickle (binary)</p>

@ -203,9 +203,12 @@
<span class="c1"># Start import after config the pyOpenRPA folder</span>
<span class="kn">from</span> <span class="nn">pyOpenRPA.Orchestrator</span> <span class="kn">import</span> <span class="n">SettingsTemplate</span> <span class="c1"># Import functionallity</span>
<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s2">&quot;__main__&quot;</span><span class="p">:</span> <span class="c1"># New init way - allow run as module -m PyOpenRPA.Orchestrator</span>
<span class="kn">from</span> <span class="nn">pyOpenRPA</span> <span class="kn">import</span> <span class="n">Orchestrator</span> <span class="c1"># Import orchestrator main</span>
<span class="c1">#Run as administrator</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">Orchestrator</span><span class="o">.</span><span class="n">OrchestratorIsAdmin</span><span class="p">():</span>
<span class="n">Orchestrator</span><span class="o">.</span><span class="n">OrchestratorRerunAsAdmin</span><span class="p">()</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Orchestrator will be run as administrator!&quot;</span><span class="p">)</span>
<span class="k">elif</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s2">&quot;__main__&quot;</span><span class="p">:</span> <span class="c1"># New init way - allow run as module -m PyOpenRPA.Orchestrator</span>
<span class="n">gSettings</span> <span class="o">=</span> <span class="n">SettingsTemplate</span><span class="o">.</span><span class="n">Create</span><span class="p">(</span><span class="n">inModeStr</span><span class="o">=</span><span class="s2">&quot;BASIC&quot;</span><span class="p">)</span> <span class="c1"># Create GSettings with basic configuration - no more config is available from the box - you can create own</span>
<span class="c1"># TEST Add User ND - Add Login ND to superuser of the Orchestrator</span>
@ -255,7 +258,6 @@
<span class="c1"># Call the orchestrator def</span>
<span class="n">Orchestrator</span><span class="o">.</span><span class="n">Orchestrator</span><span class="p">(</span><span class="n">inGSettings</span><span class="o">=</span><span class="n">gSettings</span><span class="p">,</span> <span class="n">inDumpRestoreBool</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;!WARNING! Current orchestrator settings do not support old type of the Orchestrator start. Use new Orchestrator type start (see v1.2.0)&quot;</span><span class="p">)</span>

@ -506,7 +506,30 @@
<span class="n">os</span><span class="o">.</span><span class="n">execl</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">executable</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="vm">__file__</span><span class="p">),</span> <span class="o">*</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">)</span>
<span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span></div>
<div class="viewcode-block" id="OrchestratorSessionSave"><a class="viewcode-back" href="../../../Orchestrator/02_Defs.html#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionSave">[docs]</a><span class="k">def</span> <span class="nf">OrchestratorSessionSave</span><span class="p">(</span><span class="n">inGSettings</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<div class="viewcode-block" id="OrchestratorIsAdmin"><a class="viewcode-back" href="../../../Orchestrator/02_Defs.html#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorIsAdmin">[docs]</a><span class="k">def</span> <span class="nf">OrchestratorIsAdmin</span><span class="p">():</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Check if Orchestrator process is running as administrator</span>
<span class="sd"> :return: True - run as administrator; False - not as administrator</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">return</span> <span class="n">ctypes</span><span class="o">.</span><span class="n">windll</span><span class="o">.</span><span class="n">shell32</span><span class="o">.</span><span class="n">IsUserAnAdmin</span><span class="p">()</span>
<span class="k">except</span><span class="p">:</span>
<span class="k">return</span> <span class="kc">False</span></div>
<div class="viewcode-block" id="OrchestratorRerunAsAdmin"><a class="viewcode-back" href="../../../Orchestrator/02_Defs.html#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorRerunAsAdmin">[docs]</a><span class="k">def</span> <span class="nf">OrchestratorRerunAsAdmin</span><span class="p">():</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Check if not admin - then rerun orchestrator as administrator</span>
<span class="sd"> :return: True - run as administrator; False - not as administrator</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">OrchestratorIsAdmin</span><span class="p">():</span>
<span class="c1"># Re-run the program with admin rights</span>
<span class="n">ctypes</span><span class="o">.</span><span class="n">windll</span><span class="o">.</span><span class="n">shell32</span><span class="o">.</span><span class="n">ShellExecuteW</span><span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="s2">&quot;runas&quot;</span><span class="p">,</span> <span class="n">sys</span><span class="o">.</span><span class="n">executable</span><span class="p">,</span> <span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">),</span> <span class="kc">None</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;!SKIPPED! Already run as administrator!&quot;</span><span class="p">)</span></div>
<div class="viewcode-block" id="OrchestratorSessionSave"><a class="viewcode-back" href="../../../Orchestrator/02_Defs.html#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionSave">[docs]</a><span class="k">def</span> <span class="nf">OrchestratorSessionSave</span><span class="p">(</span><span class="n">inGSettings</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Orchestrator session save in file</span>
<span class="sd"> _SessionLast_RDPList.json (encoding = &quot;utf-8&quot;)</span>
@ -534,7 +557,7 @@
<span class="k">if</span> <span class="n">lL</span><span class="p">:</span> <span class="n">lL</span><span class="o">.</span><span class="n">exception</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Exception when dump data before restart the Orchestrator&quot;</span><span class="p">)</span>
<span class="k">return</span> <span class="kc">True</span></div>
<div class="viewcode-block" id="OrchestratorSessionRestore"><a class="viewcode-back" href="../../../Orchestrator/02_Defs.html#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionRestore">[docs]</a><span class="k">def</span> <span class="nf">OrchestratorSessionRestore</span><span class="p">(</span><span class="n">inGSettings</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<div class="viewcode-block" id="OrchestratorSessionRestore"><a class="viewcode-back" href="../../../Orchestrator/02_Defs.html#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionRestore">[docs]</a><span class="k">def</span> <span class="nf">OrchestratorSessionRestore</span><span class="p">(</span><span class="n">inGSettings</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Check _SessionLast_RDPList.json and _SessionLast_StorageDict.pickle in working directory. if exist - load into gsettings</span>
<span class="sd"> # _SessionLast_StorageDict.pickle (binary)</span>
@ -551,7 +574,7 @@
<span class="n">lSessionLastRDPList</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">lFile</span><span class="o">.</span><span class="n">read</span><span class="p">())</span>
<span class="n">lFile</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> <span class="c1"># Close the file</span>
<span class="n">os</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="s2">&quot;_SessionLast_RDPList.json&quot;</span><span class="p">)</span> <span class="c1"># remove the temp file</span>
<span class="n">gSettingsDict</span><span class="p">[</span><span class="s2">&quot;RobotRDPActive&quot;</span><span class="p">][</span><span class="s2">&quot;RDPList&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">lSessionLastRDPList</span> <span class="c1"># Set the last session dict</span>
<span class="n">inGSettings</span><span class="p">[</span><span class="s2">&quot;RobotRDPActive&quot;</span><span class="p">][</span><span class="s2">&quot;RDPList&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">lSessionLastRDPList</span> <span class="c1"># Set the last session dict</span>
<span class="k">if</span> <span class="n">lL</span><span class="p">:</span> <span class="n">lL</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;RDP Session List was restored from previous Orchestrator session&quot;</span><span class="p">)</span>
<span class="c1"># _SessionLast_StorageDict.pickle (binary)</span>
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">&quot;_SessionLast_StorageDict.pickle&quot;</span><span class="p">):</span>
@ -2059,17 +2082,11 @@
<span class="kn">from</span> <span class="nn">..</span> <span class="kn">import</span> <span class="n">__version__</span> <span class="c1"># Get version from the package</span>
<span class="k">def</span> <span class="nf">Orchestrator</span><span class="p">(</span><span class="n">inGSettings</span><span class="p">,</span> <span class="n">inDumpRestoreBool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">Orchestrator</span><span class="p">(</span><span class="n">inGSettings</span><span class="p">,</span> <span class="n">inDumpRestoreBool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">inRunAsAdministratorBool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">):</span>
<span class="n">lL</span> <span class="o">=</span> <span class="n">inGSettings</span><span class="p">[</span><span class="s2">&quot;Logger&quot;</span><span class="p">]</span>
<span class="c1"># https://stackoverflow.com/questions/130763/request-uac-elevation-from-within-a-python-script</span>
<span class="k">def</span> <span class="nf">is_admin</span><span class="p">():</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">return</span> <span class="n">ctypes</span><span class="o">.</span><span class="n">windll</span><span class="o">.</span><span class="n">shell32</span><span class="o">.</span><span class="n">IsUserAnAdmin</span><span class="p">()</span>
<span class="k">except</span><span class="p">:</span>
<span class="k">return</span> <span class="kc">False</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">is_admin</span><span class="p">():</span>
<span class="c1"># Re-run the program with admin rights</span>
<span class="n">ctypes</span><span class="o">.</span><span class="n">windll</span><span class="o">.</span><span class="n">shell32</span><span class="o">.</span><span class="n">ShellExecuteW</span><span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="s2">&quot;runas&quot;</span><span class="p">,</span> <span class="n">sys</span><span class="o">.</span><span class="n">executable</span><span class="p">,</span> <span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">),</span> <span class="kc">None</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">OrchestratorIsAdmin</span><span class="p">()</span> <span class="ow">and</span> <span class="n">inRunAsAdministratorBool</span><span class="o">==</span><span class="kc">True</span><span class="p">:</span>
<span class="n">OrchestratorRerunAsAdmin</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="c1"># Code of your program here</span>
<span class="c1">#mGlobalDict = Settings.Settings(sys.argv[1])</span>

@ -276,6 +276,10 @@
<h2 id="O">O</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="Orchestrator/02_Defs.html#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorIsAdmin">OrchestratorIsAdmin() (in module pyOpenRPA.Orchestrator.__Orchestrator__)</a>
</li>
<li><a href="Orchestrator/02_Defs.html#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorRerunAsAdmin">OrchestratorRerunAsAdmin() (in module pyOpenRPA.Orchestrator.__Orchestrator__)</a>
</li>
<li><a href="Orchestrator/02_Defs.html#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorRestart">OrchestratorRestart() (in module pyOpenRPA.Orchestrator.__Orchestrator__)</a>
</li>
<li><a href="Orchestrator/02_Defs.html#pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionRestore">OrchestratorSessionRestore() (in module pyOpenRPA.Orchestrator.__Orchestrator__)</a>

Binary file not shown.

File diff suppressed because one or more lines are too long

@ -138,18 +138,28 @@ Work with activity scheduling.
| Verify user credentials in windows.
|
| `OrchestratorIsAdmin`()
| Check if Orchestrator process is running as administrator
|
| `OrchestratorRerunAsAdmin`()
| Check if not admin - then rerun orchestrator as administrator
|
| `OrchestratorRestart`([inGSettings])
| Orchestrator restart
|
| `OrchestratorSessionRestore`([inGSettings])
| `OrchestratorSessionRestore`(inGSettings)
| Check _SessionLast_RDPList.json and _SessionLast_StorageDict.pickle in working directory. if exist - load into gsettings # _SessionLast_StorageDict.pickle (binary) _SessionLast_RDPList.json (encoding = “utf-8”) _SessionLast_StorageDict.pickle (binary).
|
| `OrchestratorSessionSave`([inGSettings])
| `OrchestratorSessionSave`(inGSettings)
| Orchestrator session save in file
@ -794,6 +804,26 @@ Verify user credentials in windows. Return bool
### pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorIsAdmin()
Check if Orchestrator process is running as administrator
* **Returns**
True - run as administrator; False - not as administrator
### pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorRerunAsAdmin()
Check if not admin - then rerun orchestrator as administrator
* **Returns**
True - run as administrator; False - not as administrator
### pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorRestart(inGSettings=None)
Orchestrator restart
@ -804,7 +834,7 @@ Orchestrator restart
### pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionRestore(inGSettings=None)
### pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionRestore(inGSettings)
Check _SessionLast_RDPList.json and _SessionLast_StorageDict.pickle in working directory. if exist - load into gsettings
# _SessionLast_StorageDict.pickle (binary)
@ -823,7 +853,7 @@ Check _SessionLast_RDPList.json and _SessionLast_StorageDict.pickle in working d
### pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionSave(inGSettings=None)
### pyOpenRPA.Orchestrator.__Orchestrator__.OrchestratorSessionSave(inGSettings)
Orchestrator session save in file
_SessionLast_RDPList.json (encoding = “utf-8”)

@ -23,9 +23,12 @@ if lPyOpenRPASourceFolderPathStr != "": sys.path.insert(0,os.path.abspath(os.pat
# Start import after config the pyOpenRPA folder
from pyOpenRPA.Orchestrator import SettingsTemplate # Import functionallity
if __name__ == "__main__": # New init way - allow run as module -m PyOpenRPA.Orchestrator
from pyOpenRPA import Orchestrator # Import orchestrator main
#Run as administrator
if not Orchestrator.OrchestratorIsAdmin():
Orchestrator.OrchestratorRerunAsAdmin()
print(f"Orchestrator will be run as administrator!")
elif __name__ == "__main__": # New init way - allow run as module -m PyOpenRPA.Orchestrator
gSettings = SettingsTemplate.Create(inModeStr="BASIC") # Create GSettings with basic configuration - no more config is available from the box - you can create own
# TEST Add User ND - Add Login ND to superuser of the Orchestrator
@ -75,7 +78,6 @@ if __name__ == "__main__": # New init way - allow run as module -m PyOpenRPA.Orc
# Call the orchestrator def
Orchestrator.Orchestrator(inGSettings=gSettings, inDumpRestoreBool=False)
else:
print("!WARNING! Current orchestrator settings do not support old type of the Orchestrator start. Use new Orchestrator type start (see v1.2.0)")

Loading…
Cancel
Save