Using codemirror to execute code on server - codemirror

Novice to Codemirror.
I have codemirror running on my server I have it set to Python mode. Can someone please suggest how I go about executing the code and showing the result on the page where I have written the python code
Thanks

Without knowing much about your setup, here's a general idea:
Use the getValue() method to get the code from your CodeMirror instance.
Assuming the code is a run-able Python script, you can either
(1) send the code to your back end with AJAX or a POST request and run it there. Or (2) you could run the Python script in the browser with a library like one discussed here.
If you ran it on the back end, you can send the result of running the code back as text or JSON with your preferred protocol. If you ran it on the browser, you should probably follow the guidelines for the specific library you used.

Related

Using API POST command to 'Type' to console in PythonAnywhere. I can successfully 'Type' to the console, but how do I actually submit the command?

Currently using the PythonAnywhere API to attempt to access a Python script I wrote that is hosted in a Virtual Environment in PythonAnywhere. Using the Bubble API Connector if that matters.
I figured out how to use the POST command in combination with "/api/v0/user/{username}/consoles/{id}/send_input/" to successfully send the text "python HelloWorld.py" to my PA console. However, I don't know how to get the API to actually have the console execute that command / text. Is there some text that represents hitting the 'Enter' button or something of that nature?
Sorry if this is a dumb question or has an obvious solution but I am pretty new to this.
Thanks in advance.
Tried new line tag "/n" as well as combing the PA forums, but no luck finding this specific topic.
Expecting my text to end up in the console (which is happening) and for it to Execute (not happening).

How to debug ExecuteFunctions for word add-in?

I'm implementing a functionality which runs in background(without Taskpanel), where I can POST the word document data to REST API through the ExecuteFunctions. my question here is How can I debug the Function file? I tried printing through the console logs and also tried to debug through F12 and Visual studio tools, but didn't work. I have created word add-in using YO Office generator.
To answer the question as is, simplest way of debugging the functions is through the Web experience (https://onedrive.live.com), where they will print stuff on the console.
You should probably check out this answer though: Run add-in without showing taskpane?
You really can't run background tasks without having a TaskPane. Functions are meant to just plainly execute something and exit. That means; upon clicking the Function button, you can make a request and upload some data, but you can't really keep a connection open and upload periodically after just one click.

KsqlRestClient.makeKsqlRequest("RUN SCRIPT ...") doesn't work without filling ksql.schema.file.content with the script content yourself

In my Scala application, I am trying to tell my KSQL Server that it should execute the RUN SCRIPT <script> command, using the KsqlRestClient.makeKsqlRequest(String ksql) function. Every time I tried it, nothing happened, even though the response was successful, so I started debugging, where I saw that the response was a success but it also returned some kind of error that the property ksql.schema.file.content was empty.
Since I did not find any documentation as to what to fill this property with, I tried some things and eventually found out that if you fill this property with the contents of your .sql file, the run script command works.
Does anybody know if and with what ksql.schema.file.content should normally be filled and/or if the way I am using it is how your supposed to execute a script in KSQL from a Scala application. I already copy and pasted the text from the makeKsqlRequest into the KSQL CLI and everything worked fine, so there should be no error with that.
There is a Github issue tracking the fact that the RESTful API is not documented / supported yet, (as of March 2018).
It sounds like this is something you may want to add a +1 too.

Automated Testing (Watir): Retrieving data and implementing into your test?

I am just getting started with automated testing on RubyMine using Watir webdriver. So far I am having a blast and I find it works really well, even for a newb like me! :)
I want to create a test which retrieves an order code that is generated during the test and then later use the same code to run an 'include?' verification query on a different page.
I know I can use an HTML selector to show Watir where the code is, I want to know how to copy it and use it later. Can anyone point me in the right direction?

How to suppress display of password in Selenium RC window

I am writing some Selenium RC tests using the perl library WWW::Selenium. At the beginning of the test I need to login to a web form using my username and password.
I noticed that my password is displayed in the Selenium Remote Control "Command History" window as type(password, secret).
Is there any way to suppress the display of the password? Maybe there is a command other than type I can use?
Unfortunately no. You could go into the Selenium core and change it to show ******* when it finds a field named password.
Beware though that this could make life difficult when debugging
I guess we can do this using native methods support.
Think logically every native methods in selenium will be sent to the operating system not to the browser.
So if you use any of the native methods, the flow is like this:
Client Program ----> Selenium RC server ----> to the operating system (in Java this is done using Robot Class)
But all the other non-native methods flow is like this:
Client Program ----> Selenium RC server ----> to the Browser
So, the Command History window operates at the Browser level and the native methods will not reach there.
Here is the code:
selenium.focus("locator");
selenium.keyPressNative("key code"); // this will not be shown in command history
Here the key code is only for one character and if you want string (more than one character), we should rely on our client program to implement the logic.
I have given that code in my previous answers to other posts. If you need it personalised post our exact requirement so that I can give that code tailored to your need.