I am trying to get the Jenkins last successful build output using api4jenkins library. I can get the build number, but unable to find the option to download consoletext. Is that option available in this framework?
if not any other way to download the console text using cli?
Thanks
SR
You can do something like this.
from api4jenkins import Jenkins
j = Jenkins('http://localhost:8080', auth=('admin', 'admin'))
job = j['Sample'] # Getting the Job by name
for line in job.get_build(1).console_text():
print(line)
Also remember it's always possible to directly download the log as well. For example refer the following.
http://localhost:8080/job/<JOBNAME>/lastSuccessfulBuild/consoleText
Related
I have completed a tiny selenium spider project with Browsermob-Proxy, but the Browsermob-Proxy written by java, I need to package whole project file into a single executable file, but use Browsermob-Proxy is unavailable job!
So I plan use mitmproxy that written by python, but I can’t find any documentation mention that how can return response or request data directly in python script code without saving data in alternative text file.
If can use the method of Browsermob-Proxy,it’s the best solution, like this
BMPproxy.new_har("video",options={'captureContent': True,'captureContent': True})
# selenium code
brosver.get(url)
brosver.find_element_by_xpath('//*[#id="kw"]').send_keys("python")
brosver.find_element_by_xpath('//*[#id="su"]').click()
json_data = BMPproxy.har
I am a very newbie and currently working for my Final Project. I watch a youtube video that teach me to code Abstractive Text Summarization with google's Pegasus library. It Works fine but I need it to be more efficient.
So here is the code
from transformers import PegasusForConditionalGeneration, PegasusTokenizer
tokenizer = PegasusTokenizer.from_pretrained("google/pegasus-xsum")
model = PegasusForConditionalGeneration.from_pretrained("google/pegasus-xsum")
Everytime I run that code, it always download the "Google Pegasus-xsum" library which sized about 2.2 GB.
So here is the sample of the code in notebook : https://github.com/nicknochnack/PegasusSummarization/blob/main/Pegasus%20Tutorial.ipynb
and it will running download the library like picture below :
Is there any way to download the library first and then I saved it locally, and everytime I run the code it's just gonna call the library locally?
Something like caching or saving the library locally maybe?
Thanks.
Mac
Using inspect you can find and locate the modules easily.
import inspect
from transformers import PegasusForConditionalGeneration, PegasusTokenizer
tokenizer = PegasusTokenizer.from_pretrained("google/pegasus-xsum")
model = PegasusForConditionalGeneration.from_pretrained("google/pegasus-xsum")
print(inspect.getfile(PegasusForConditionalGeneration))
print(inspect.getfile(PegasusTokenizer))
You will get their paths sth like this
/usr/local/lib/python3.9/site-packages/transformers/models/pegasus/modeling_pegasus.py
/usr/local/lib/python3.9/site-packages/transformers/models/pegasus/tokenization_pegasus.py
Now, if you go and see what is inside the tokenization_pegasus.py file, you will notice that the model of google/pegasus-xsum is being probably fetched by the following line
PRETRAINED_VOCAB_FILES_MAP = {
"vocab_file": {"google/pegasus-xsum": "https://huggingface.co/google/pegasus-xsum/resolve/main/spiece.model"}
}
where here if you open:
https://huggingface.co/google/pegasus-xsum/resolve/main/spiece.model
You will get the model downloaded directly to your machine.
UPDATE
After some search on Google, I've found sth important where you can get the used models and all their related files downloaded to your working directory by the following
tokenizer.save_pretrained("local_pegasus-xsum_tokenizer")
model.save_pretrained("local_pegasus-xsum_tokenizer_model")
Ref:
https://github.com/huggingface/transformers/issues/14561
So that after running it, you will see the following being saved automatically in your working directory. So, now you can call the models directly but you need to search how...
Also, the 12.2GB file that you wanted to know its path locally, it is being located here online
https://huggingface.co/google/pegasus-xsum/tree/main
And after downloading the models to your directory as you can see from the screenshot its name is pytorch_model.bin as it’s named online.
We have commands to get last_build_number, get_build_console_output, build_job_url etc with python_jenkins. But, I want to fetch the url of the latest successful build a jenkins job that executes selenium test. Is there any way to get it with either python-jenkins or any other method. Please share it to me.
Thanks in advance
See this example for getting next build number. You need to replace nexBuildNumber with lastSuccessfulBuild
Let say I'm creating an issue in Jira and write the summary and the description. Is it possible to call a python script after these are written that sets the value for another field, depending on the values of the summary and the description?
I know how to create an issue and change fields from a python script using the jira-python module. But I have not find a solution for using a python script while editing/creating the issue manually in Jira. Does anyone have an idea of how I manage that?
I solved the problem by using the Add-on Script runner in Jira. There I created a scripted field in Groovy and called the command prompt and run the python script from there. Here is a simple example of the script
def process = ['cmd', '/c', 'filepathToPython.exe', 'filepathToPythonFile.py'].execute()
process.waitfor()
return p.text
process?.err?.text can be used instead of process.text if one want to see eventual error messages.
Take a look at JIRA webhooks calling a small python based web server?
I've been searching for this for some time, but I couldn't seem to find a way to achieve this.
What I want to do is that I need the functionality of web page to pdf conversion from firefox. Right now the web page is generated in my django application and I use an open source software called "pisa"(or "xhtml2pdf") to get pdf report. However, it only supports very limited css styles, and some of the images are not rendering properly. After trying several possibilities, I found that firefox gives exactly what I want though printing web page to pdf file option in the brower gui, so I'm wondering if I could use python or command line to make firefox does the same thing. I would be very appreciated if somebody can pointing me to some resources for firefox commands or python api. Thanks.
To print from the command line with Firefox, you need to install an extension. One such extension is
Command Line Print by torisugari.
This extension allows you to print URLs immediately, without user interaction. This can be useful to convert html pages to PDF for example.
You first have to install the extension from http://torisugari.googlepages.com/commandlineprint2
After you've properly installed the extension, you can start using Firefox as command line printer.
Usage:
$>firefox -print http://www.example.com/index.html
$>firefox -print http://www.example.com/index.html -printmode pdf -printfile foobar.pdf
$>firefox -print http://www.example.com/index.html -printmode PNG
from here Command Line Print - torisugari -> https://sites.google.com/site/torisugari/commandlineprint2
now you must add your page like 127.0.0.1/yourpage with django webserver
so with loop and address you can print all page
Take a look at wkhtmltopdf.
It is a simple command line Utility, using the WebKit rendering engine, which is also used by Google Chrome and Apple Safari.