Disable warning message in scribus - python

When importing a svg file to the DTP programme "Scribus" it shows a warning message (with just one OK-button), that has to be confirmed to go on. This stops my Python Script from working.
So I need a possibility to either confirm the message or - even better - to stop Scribus from showing this message. (something like the "Application.DisplayAlerts = False" in Excel VBA)
A possible solution would be to send an "Enter" command using sendkeys, but I don't like that because the command could miss the target.

Have a look here:
https://pypi.python.org/pypi/pywinauto/0.5.1
and here:
http://pywinauto.github.io/
It might not be a ready solution to your challenge within Scribus, but it might point you in the right direction. Or the developers could help you.
Check the Scribus website too, there is a very helpful mailing list running, which has helped me several times.
And could some veteran please create a "Scribus" tag here?

contributors are working on refactoring those parts of code where scribus blocks the scripts with popups.
patches have already been applied to the 1.5svn development version to better manage them.
my hint to you:
use the stable version for creating your documents
but -- as long as the new stable 1.6 is not out -- use scribus 1.5 for running your scripts unattended, using the documents you created with 1.4
and if you then hit further stoppers report them to the scribus issues tracker (or make a patch and submit it there!)

Related

How to run python code directly on a webpage

My problem is as follows:
I have written a python code, and I need to run it on a web page.Basically I need that whatever is on the console should be displayed as it is.
I have no experience in web development and similar libraries, and I need to get this done in a short time. Kindly tell how should I proceed?
Note: I might be plotting some graphs also. It would be great if they could be displayed all at once(sequentially) on the website
https://brython.info/
https://skulpt.org/
https://pyodide.org/en/stable/
There are multiple python implementation on browser, some are webassemble some are javascript.
Is it a good idea to run python on browser as a replacement for javascript in 2022? No it is not, learn javascript. No in-browser python implementation can race with javascript as of today and most probably ever.
You Can't execute Python-Code directly inside a webbrowser - however, you could for instance create a basic IDE in HTML & JS, send code written by a user on the page to a Server, which would then run the code and send the results back to the client-page.
Unfortunately, such a project is quite ambitious and complicated, especially when Security & Stability are of mayor concern, as executing client-code is a very dangerous measure indeed, and requires expertise in Virtualization Techniques & Software.
Another Method could be to use a public API, which allows you to run Python code and fetch the results back. The procedure would be exactly the same as with the previous idea in terms of creating the web-client, but the heavy-lifting - which is actually executing the Python-code, would be taken care of for you.
As you can see, there is no concrete answer to this question, only suggestions.
A few useful links below:
https://docs.docker.com/
https://appdividend.com/2022/01/18/best-python-online-ide/
https://www.makeuseof.com/tag/programmer-browser-ides/
https://www.youtube.com/watch?v=og9Gaj1Hzag
How do I execute a string containing Python code in Python?

python script placement in apache

This would lead to a more nvolved question, but I could use some help with such things as search terms to use to find more info, links (someone has already done this, etc.).
First of all, lets assume a centos7/apache/mod_wsgi serverset up.
Lets also assume no django, no nginx, no bootstrap,no php, possibly not even a database.
(That should narrow things down quite a bit).
I want to use 2 or 3 python scripts (maybe more), but 3 main ones.
Now, let's say I have an html page with a button,a href that calls a python script. What choices do I have on where to put this script? Right in the apache root directory, the cgi-bin, somewhere else? And let's say this button and script takes the user into a protected directory (the same script - is that possible?). And hooks up to another python script that does some math - maybe random numbers, and leads to another python script that sends the user somewhere else - another html page? Sorry, this is pretty vague - which is why I'm asking the question - need more info. And I think this also applies to security, a lot of these questions and answers are very outdated. Where's the best place to place python scripts in apache?
Try this for a start: https://www.linux.com/blog/configuring-apache2-run-python-scripts.
Once you've got it running, take the next step (i.e. adapt your python code to do what you want it to do).
Does that help you to take a step towards your goal?

How do I generate the Minecraft launch command for versions 1.8+ in Python?

I am currently working on a little Python project that will function as a custom and highly-configurable launcher for the popular game Minecraft to practice new skills I have been learning recently! However, I am having one problem really throwing me for a loop, and it's just how Minecraft goes about launching the actual game. From my extensive searching, I have learned that the new Minecraft login system sends the user's username and password to authserver.mojang.com/authenticate (the endpoint changing depending on just what is being done) and is returned with an access token, which can be used to log into the game.
(Edit:) What I am asking of you guys is how I would transform the data about where the game is installed and the data received from the POST request into a command that launches the game, alike how it is done in the default launcher. Overnight, I considered looked into the source of the FTB launcher and found this. This is the class for creating this launch command. How could I recreate this in Python?
Note, this question is not a duplicate, the potential duplicates in question are here and here. Both of these questions are relevant to the old launcher, but the new launcher uses a much different process.
Additionally, I have tried the strategy found here. This does not appear to work correctly on later versions, however. Edit: There was a small detail regarding the natives folder I missed. Basically, if I rename the folder to make a static copy, I can then change the natives directory in the command. However, the command still cannot be generated this way for various users.
If anyone has any ideas about this, feedback is much appreciated! Thanks!

Programatically report goo.gl shortened URL as spam?

I have a list of more than 3500 goo.gl URLs which have been identified as spam.
I need to report them to Google as spamlinks. Google indeed provided a page to report these kinds of spamlinks: https://goo.gl/#reportspam ... unfortunately, it only accepts on and exactly one URL per reporting.
Naturally, 3500+ of URLs means it's no longer sane nor practical to report them manually, one-by-one. Spamlink reporting must be done automatically.
I have been reading Google's URL Shortener API documentation, and I have also searched the Internet for relevant information, but I can't seem to find any publicly available API for reporting goo.gl linkspams.
Can you direct me to how I can accomplish this automated linkspam reporting?
If possible, with a sample code, preferably using Python.
Just an update: I give up. Too much work to do.
I finally resorted to driving / simulating mouse-clicks and typing using xdotool and a bash script, running non-stop within a VirtualBox VM (so it can run in the background while I do things in the foreground).
It's not perfect. But it works well enough for my needs. If I left the VM + Script running overnight, it can report over 9'000 spam URLs.
If you're interested in the script, I've uploaded it here:
https://bitbucket.org/snippets/pepoluan/78M4X
(too long to paste in StackOverflow)
And this is how everything should be laid out before running the script (note particularly how Firefox is placed flush right and flush top).
(Note: It's on Linux Mint 17.3 with MATE. On other WMs / distros, you'll need to change the xpos and ypos values to match the actual layout. Move the mouse so that the pointer hover over the relevant textbox, and use the xdotool getmouselocation command.)
(Another very important note: DISABLE CLIPBOARD SHARING! You'll save yourself a lot of time wondering why everything go wonky.)
I hope this can be of help to someone!

Lightweight console/IDE for Python?

I often use ipython (or the regular python shell) to test python code snippets while coding, and it's been very useful. One shortcoming of this, though, is that if I want to test a multi-line segment of code, or want to write multiple lines of code before running, it isn't very convenient to have to do it "line by line". And even going back to change some of the lines is cumbersome because you have to re-type all the code that comes after it.
I'm playing with Groovy right now and I find that it has an excellent solution to this problem: the Groovy Console. You just write all the code you want, it's just like a regular editor; and then you hit run Ctrl+R (Cmd+R actually since I'm on a Mac) and it runs everything at once. If you want to change something (e.g. if there are errors), then that's easy too -- just change it and Ctrl+R again.
Is there an equivalent of this available for python? Or do you have any recommendations on a way to achieve similar behavior? I could just create a new file, save it, and then python <filename>.py from the shell. But that's just too many steps and would be cumbersome. Eclipse may be an option, but it's too heavyweight. I'm really looking for something lightweight that I can just spin up when I want to test something and then get rid of it just as quickly.
I'd be interested to hear any ideas/suggestions!
Thanks
You might give DreamPie a try. As far as I can tell from a quick read of the groovyConsole page you linked to, DreamPie features a similar input area/output area division (they call it "code box" and "history box"). The code you execute is by default cleared from the code box - which groovyConsole apparently doesn't do - but you can easily retrieve it (Ctrl+Up), or change a preference setting to "Leave code in the code box after execution".
Have you tried using IDLE, the standard Python IDE? You'd have to save the code as <filename>.py within IDLE, but after that you can run it using F5.
The Python docs link to this intro to IDLE, which may be helpful even if it's a little outdated.
I am using emacs and its python-mode.
C-c C-c: evals the current buffer
but you can also eval region (ie selection), functions etc ...
You can even make python-mode use ipython (like I do).
See http://ipython.scipy.org/dist/ipython.el . It works nicely
Did you try PyCrust? It has excellent multi-line editing, copy/paste support.
PyCrust can be found in wxPython Docs and Demos.

Categories