summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorJean-Pierre Ledure <jp@ledure.be>2021-02-21 15:48:01 +0100
committerJean-Pierre Ledure <jp@ledure.be>2021-02-21 17:06:18 +0100
commit4b448758a98670efe259965829e5ce0861392caf (patch)
tree96dfc517b1384bf5f915dc587e937bcf53f37f47 /wizards
parent301b09f0c4fef6fca52fa0b28827a657bbbb6b39 (diff)
ScriptForge - (SF_Platform) new Locale and PythonVersion properties
- 'Locale' returns a la-CO (language-COUNTRY) string derived from com.sun.star.lang.Locale - 'PythonVersion' returns Python major.minor.patchlevel supplied by ScriptForgeHelper.py platform class Change-Id: I2b8495c03253b17c5e4ba14765b1f359eee67813 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111284 Tested-by: Jean-Pierre Ledure <jp@ledure.be> Tested-by: Jenkins Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Diffstat (limited to 'wizards')
-rw-r--r--wizards/source/scriptforge/SF_Platform.xba24
-rw-r--r--wizards/source/scriptforge/python/ScriptForgeHelper.py5
2 files changed, 28 insertions, 1 deletions
diff --git a/wizards/source/scriptforge/SF_Platform.xba b/wizards/source/scriptforge/SF_Platform.xba
index 80f3ab97a182..69045404b5ba 100644
--- a/wizards/source/scriptforge/SF_Platform.xba
+++ b/wizards/source/scriptforge/SF_Platform.xba
@@ -71,6 +71,14 @@ Property Get CurrentUser() As String
End Property &apos; ScriptForge.SF_Platform.CurrentUser (get)
REM -----------------------------------------------------------------------------
+Property Get Locale() As String
+&apos;&apos;&apos; Returns the locale combining language-COUNTRY (la-CO)
+&apos;&apos;&apos; Example:
+&apos;&apos;&apos; MsgBox platform.Locale
+ Locale = _PropertyGet(&quot;Locale&quot;)
+End Property &apos; ScriptForge.SF_Platform.Locale (get)
+
+REM -----------------------------------------------------------------------------
Property Get Machine() As String
&apos;&apos;&apos; Returns the machine type like &apos;i386&apos; or &apos;x86_64&apos;
&apos;&apos;&apos; Example:
@@ -138,6 +146,14 @@ Property Get Processor() As String
Processor = _PropertyGet(&quot;Processor&quot;)
End Property &apos; ScriptForge.SF_Platform.Processor (get)
+REM -----------------------------------------------------------------------------
+Property Get PythonVersion() As String
+&apos;&apos;&apos; Returns the Python version as string &apos;Python major.minor.patchlevel&apos;
+&apos;&apos;&apos; Example:
+&apos;&apos;&apos; MsgBox platform.PythonVersion &apos; Python 3.7.7
+ PythonVersion = _PropertyGet(&quot;PythonVersion&quot;)
+End Property &apos; ScriptForge.SF_Platform.PythonVersion (get)
+
REM ===================================================================== METHODS
REM -----------------------------------------------------------------------------
@@ -190,6 +206,7 @@ Public Function Properties() As Variant
, &quot;ComputerName&quot; _
, &quot;CPUCount&quot; _
, &quot;CurrentUser&quot; _
+ , &quot;Locale&quot; _
, &quot;Machine&quot; _
, &quot;OfficeVersion&quot; _
, &quot;OSName&quot; _
@@ -197,6 +214,7 @@ Public Function Properties() As Variant
, &quot;OSRelease&quot; _
, &quot;OSVersion&quot; _
, &quot;Processor&quot; _
+ , &quot;PythonVersion&quot; _
)
End Function &apos; ScriptForge.SF_Platform.Properties
@@ -238,6 +256,7 @@ Private Function _PropertyGet(Optional ByVal psProperty As String) As Variant
&apos;&apos;&apos; psProperty: the name of the property
Dim sOSName As String &apos; Operating system
+Dim oLocale As Object &apos; com.sun.star.lang.Locale
Const cstPyHelper = &quot;$&quot; &amp; &quot;_SF_Platform&quot;
Dim cstThisSub As String
@@ -248,10 +267,13 @@ Const cstSubArgs = &quot;&quot;
Select Case psProperty
Case &quot;Architecture&quot;, &quot;ComputerName&quot;, &quot;CPUCount&quot;, &quot;CurrentUser&quot;, &quot;Machine&quot; _
- , &quot;OSPlatform&quot;, &quot;OSRelease&quot;, &quot;OSVersion&quot;, &quot;Processor&quot;
+ , &quot;OSPlatform&quot;, &quot;OSRelease&quot;, &quot;OSVersion&quot;, &quot;Processor&quot;, &quot;PythonVersion&quot;
With ScriptForge.SF_Session
_PropertyGet = .ExecutePythonScript(.SCRIPTISSHARED, _SF_.PythonHelper &amp; cstPyHelper, psProperty)
End With
+ Case &quot;Locale&quot;
+ Set oLocale = SF_Utils._GetUNOService(&quot;Locale&quot;)
+ _PropertyGet = oLocale.Language &amp; &quot;-&quot; &amp; oLocale.Country
Case &quot;OfficeVersion&quot;
_PropertyGet = _GetProductName()
Case &quot;OSName&quot;
diff --git a/wizards/source/scriptforge/python/ScriptForgeHelper.py b/wizards/source/scriptforge/python/ScriptForgeHelper.py
index ca520434a2a9..aec9311a3f3f 100644
--- a/wizards/source/scriptforge/python/ScriptForgeHelper.py
+++ b/wizards/source/scriptforge/python/ScriptForgeHelper.py
@@ -171,6 +171,8 @@ def _SF_Platform(propertyname: str): # used by SF_Platform Basic module
return pf.OSVersion
elif propertyname == 'Processor':
return pf.Processor
+ elif propertyname == 'PythonVersion':
+ return pf.PythonVersion
else:
return None
@@ -210,6 +212,9 @@ class Platform(object, metaclass = _Singleton):
@property # real processor name e.g. 'amdk'
def Processor(self): return platform.processor()
+ @property # Python major.minor.patchlevel
+ def PythonVersion(self): return 'Python ' + platform.python_version()
+
# #################################################################
# Session service