I am not able to set a variable in the path , with using "set" command when i retrieve my variable it giver back NONE - environment-variables

I am using python 3.11 currently
Before i was using python 3.10.7 after this problem i have shifted to python3.11 but the problem is the same.

Related

How to set jenkins string parameter in Windows batch command

I have declared a string parameter in Jenkins i.e "Year".
The value is to be set in windows batch command, because i thought this was simple without a plugin.
Below screen depicts on how i am setting the parameter Year.
When I do echo can see in the console correct data is displayed however when I try to use the same parameter after this execution in next set as ${params.Year}, it seen as empty.
What I am doing wrong here? not able to figure it out.

how to enableJsonFunctions=1 in exasol database?

I am trying to search for exasol paramter value to enable json functions JSON_EXTRACT , JSON_VALUE etc. My exasol version is 6.2 , But unable to use the functions. Can someone quide me on how to enable it from Database ?
I have checked the values in EXA_METADATA and EXA_PARAMTER sys tables but could not find json parameter name.
enableJsonFunctions is a command line parameter. This means you have to specify it e.g. via EXAoperations (See "Extra DB Parameters" here) and this will require a database restart. Also make sure that you are at least on 6.2.7. Starting from 7.0, the json functions are available without the command line parameter.

How to refer to files that were added via the data_files attribute?

With py2app, say I added several files to my package using this:
DATA_FILES = [
('images', ['images/picture.jpg', 'images/picture2.png']),
('images/icons', ['images/icons/ico1.ico'])
]
and in my original I used to access these files using './images/picture.jpg' for example. How should I refer to them now?
I've tried both using the same path and using ./Contents/Resources//images/picture.jpg but neither work
In general, paths obtained via os.getcwd() refer to ./Contents/Resources/ after running py2app on my machine.
To better understand your exact problem, run the executable file in *.app/Contents/MacOS/, then copy and share the traceback error message that comes up in your Terminal console. Also, try to insert print statements to analyse your paths in Terminal.

How does the core 'php.ini' directive 'memory_limit' is considered as an 'Environment Variable' in an code example from the PHP Manual?

I'm using PHP 7.2.8 on my machine that runs on Windows 10 64-bit Operating System.
I come across the following code example from PHP Manual having some description :
Using environment variables can be used in php.ini as shown below.
Example #1 php.ini Environment Variables
; PHP_MEMORY_LIMIT is taken from environment
memory_limit = ${PHP_MEMORY_LIMIT}
I executed the above code on my machine it gave me the following error messages :
Warning: Use of undefined constant PHP_MEMORY_LIMIT - assumed 'PHP_MEMORY_LIMIT' (this will throw an Error in a future version of PHP) in demo.php on line 3
Notice: Undefined variable: PHP_MEMORY_LIMIT in demo.php on line 3
I checked the list of available 'Environment Variables' on my machine but I didn't get such environment variable named $_ENV['PHP_MEMORY_LIMIT']
Then, I checked the php.ini file present on my machine. I found the core php_directive memory_limit=128M
So, my question is why the code example from PHP Manual is considering something similar(${PHP_MEMORY_LIMIT}) to the core 'php.ini' directive as an 'Environment Variable'?
Also, the code written in this code example doesn't work as such environment variable named ${PHP_MEMORY_LIMIT} doesn't exist.
I even checked the latest php.ini from Git as recommended in the PHP Manual but in that file also I found the core php_directive memory_limit=128M and no environment similar to it.
Is the PHP Manual having wrong code example?
Someone please clear my doubts.
Thanks.
The first thing to note is that your example is not a code example, it's a configuration example. So it belongs on php.ini and not on a PHP file.
Environment variables are system dependent and it is up to you to set them. The manual is giving you an example with the aptly named PHP_MEMORY_LIMIT. You could set that variable on your system and then use it on your php.ini. But you can call it whatever you want, that's just an example, it's not based on any specific platform where that variable would be set.

libreoffice - run (python) macro to insert cross reference from Gnu/Linux command line

I have verified that I can run both normal office and python macros from within office but I still haven't figured out how to run one (even the hello world one) from the command line.
I have googled and looked at other answers here but I'm still not entirely clear how to run an open office macro from the command line:
https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=8232
suggests to use:
office writer.odt "macro://Standard.Module1.Macro1()"
I have also seen:
office "macro://Standard.Module1.Macro1()" writer.odt
Either way around this just opens the document and and neither runs a macro nor reports an error.
Whereas How to call an existing LibreOffice python macro from a python script
suggests to run office listening on a port and communicate via that.
If I can get that far I still need to find API documentation that will explain how to insert an anchor (as per my other question
asciidoc: is there a way to create an anchor that will be visible in libreoffice writer?)
I'm using RHEL7 for context.
update
oowriter "foo.odt" macro:///Standard.Module1.addXref
works with a office basic macro.
I still haven't figured out the python one.
One issue is I can't find any debug information to look at. Are there any log files anywhere?
Another issue is which version of python to use.
The RHEL package installs site packages for python 2.7.
>rpm -q --whatprovides /usr/bin/writer
libreoffice-writer-4.3.7.2-5.el7_2.1.x86_64
>rpm -ql libreoffice-pyuno-4.3.7.2-5.el7_2.1
...
/usr/lib64/python2.7/site-packages/uno.py
Libreoffice5.1 includes 3.5 with the distro:
>/opt/libreoffice5.1/program/python --version
Python 3.5.0
So to start with I am looking for a hello world python example that pairs a known version of python with a known version of office. Preferably either of the two above (writer 4.3.7 & python 2.7? or writer 5.1 & python 3.5).
update2
Using python3.5 as installed with office5.1 I have a working hello world using the following:
import uno
# get the uno component context from the PyUNO runtime
localContext = uno.getComponentContext()
# create the UnoUrlResolver
resolver = localContext.ServiceManager.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", localContext )
# connect to the running office
ctx = resolver.resolve( "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" )
smgr = ctx.ServiceManager
# get the central desktop object
desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",ctx)
# access the current writer document
model = desktop.getCurrentComponent()
# access the document's text property
text = model.Text
# create a cursor
cursor = text.createTextCursor()
# insert the text into the document
text.insertString( cursor, "Hello World", 0 )
This works with either version of open office via:
/usr/bin/oowriter --accept="socket,host=localhost,port=2002;urp;StarOffice.ServiceManager"
So the final part is to add the cross reference.
It looks like the command needs an extra slash. This worked for me on Ubuntu:
lowriter "Untitled 1.odt" macro:///Standard.Module1.SayHello
That calls this method in the module named Module1 under My Macros & Dialogs / Standard:
Sub SayHello
MsgBox("Hello, World!")
End Sub
The above approach only works for Basic macros. For Python macros, the standard command line approach is to connect to a listening instance of Office. Warning: This will be much (perhaps 10x) slower than running from within Office.
The link you suggested shows how to call a Python macro from a different Python script, which is more complex than what we need here. Instead, put the connecting code (starting with localContext = uno.getComponentContext()) and macro code in the same script. For an example of what should go in the script, see "First play with the Python shell to get familiar" at http://christopher5106.github.io/office/2015/12/06/openoffice-libreoffice-automate-your-office-tasks-with-python-macros.html.
As far as creating anchors, there are a number of different objects in LibreOffice that can function as anchors:
Headings
Bookmarks - example code to create them
Tables and Frames
Sections
Images and OLE Objects
This list was copied from How do I check for broken internal links in Star Basic?. In your other question you also asked about checking for broken links, so hopefully that question is helpful.
One way to create a hyperlink is to edit the HyperLinkURL property of some text. For example, say there is a bookmark called MyBookmark. Then the following code changes the currently selected text into a hyperlink:
viewcursor = currentController.getViewCursor()
viewcursor.HyperLinkURL = "#MyBookmark"
EDIT:
Regarding which version of python to use, currently LibreOffice uses python 3 and OpenOffice uses python 2.
For debugging information, you can set a checkpoint in the Basic IDE. For python, I use the logging module. OpenOffice also has various log files but I normally do not find them helpful.
Regarding problems with python, did you try the link I posted? If so, how far did you get?
I do not think you will find many RHEL examples. Try to get it working on a desktop distro like Ubuntu first, and then adapt that approach to RHEL.

Resources