NameError: name 'cas_conn' is not defined in sasoptpy - python

I'm trying to learn sasoptpy. I have installed it in my python 3.6 after that I'm trying to execute the examples
given here
Copied the complete code from here.If you want to check my code then please refer this link but while I'm running it,I'm getting error message as NameError: name 'cas_conn' is not defined Can you suggest me what should I do to avoid this error

cas_conn parameter in that example represents an active CAS (SAS Viya) connection.
SAS Viya is SAS' cloud computing solution. To be able to solve problems with sasoptpy, you will need to have a running server.
See https://sassoftware.github.io/sasoptpy/getting-started.html#creating-a-session for more information about creating a session.
If you have access to a CAS server, try the following:
from swat import CAS
cas_conn = CAS(your_cas_server, your_cas_port)
test(cass_conn)

Related

Using prolog without the pl file

My python application works well and uses swi_prolog's consult, asserts, and query functions along with a pl file. However, when I call the code via web (I get access error at consult when trying to open the pl file).
So, I thought of using the prolog without the pl file consultation. I just want to embed the pl file content into prolog in a way so that I can use it in a similar way and I can continue with the query steps. Is there anyone who can guide me in doing this?
Thanks in advance,
Ferda
The SWI-Prolog manual has a chapter on deploying applications. In particular, it allows you to create so-called saved states of your program. This mechanism allows you to create a stand-alone package from your application, either from inside the application or from the command line.

Get the application settings values (Environment) from Azure function for python

I am trying to get the application settings values from azure function for python.
I used the below code to get the Data_AzureConnection value.
logging.info("OS Env")
logging.info("Env value")
test = os.environ["Data_AzureConnection"]
logging.info(test)
But I got below result
Why I am not able to see the Data_AzureConnection value?
Is there any way to get the values from azure function for python application settings?
Please let me know if there is a solution.
It only shows Hidden Credential in the log, actually you can get it in the code by using os.environ["Data_AzureConnection"]. It returns the value in the reponse, see my test result below.

InvalidResourceType The resource type could not be found in the namespace Azure Python SDK Error

I'm hitting the following error when trying to run:
resource_client.resources.get( 'MyResourceGroup', 'Microsoft.Network', '/Resource/Group/Id', 'routeTables', 'Subnet-1-RouteTable', '2015-01-01' ):
For reference, here is the function documentation.
Error:
Message: The resource type could not be found in the namespace 'Microsoft.Network' for api version '2015-01-01'.
I've tried modifying the following without success:
changing API version to 'v2015-01-01' (I can't find any examples of anyone calling this Azure Python SDK function to figure out what the format is supposed to be, any pointer to one would be greatly appreciated)
using 'Microsoft.Network/routeTables' instead of 'routeTables'
I can't find a list of API versions, but I have seen 2015-01-01 thrown around so I used that here, but if someone has a list of APIs or one that will work for this resource type that would be great.
Is there a specific reason you don't want to use the "azure-mgmt-network" client directly?
https://learn.microsoft.com/en-us/python/api/azure.mgmt.network.v2017_03_01.operations.routetablesoperations?view=azure-python
This should simplify a lot your situation.
To answer to your specific problem, I think "routeTable" just does not exist in 2015-01-01 (as the message said). This is an old ApiVersion, and that's not even supported in official SDKs. You should try 2017-03-01.
And about the call itself example, this unittest might help you:
https://github.com/Azure/azure-sdk-for-python/blob/master/azure-mgmt/tests/test_mgmt_resource.py#L156-L164
But again, I strongly suggest you to just use the Network client and not generic Resource.
(I own the Python SDK at MS)

JIRA API components name is not valid

I am currently attempting to create an issue within JIRA via API and have been running across an issue that I have no clue to fix.
I used a curl command to find the components and I got the following:
"components":[{"self":"https://jira-server/rest/api/2/component/18458","id":"18458","name":"JIRA","description":"#"},{"self":"https://jira-server/rest/api/2/component/18463","id":"18463","name":"JIRA"}]
when I run my script by using python-JIRA API with the following command:
new_issue = jira.create_issue(project='IT', summary='New issue from jira-python', description='look here', issuetype={'name': 'Task'}, components = [{'name': "JIRA"}])
I get the following error message:
response text = {"errorMessages":[],"errors":{"components":"Component name 'JIRA' is not valid"}}
Can anyone tell me what exactly I am doing wrong? I am 100% "JIRA" is a component since I manually created a test issue and selected "JIRA" as a component.
You have to make sure the Component you're linking to belongs to the same Jira Project that your issue is being created under
I believe your issue might be that you have too many brackets, components = [{'name': "JIRA"}] should be components = {'name': "JIRA"}
This is what I think your error is trying to tell you too when it says "errorMessages":[]....., the api only expects one set of brackets and passing it a set with information enclosed in another pair sets it off.
However I have not tried this solution but I do know it works when using issuetype = {'name' : 'Bug'}
Alternatively you probably don't even need the components part, it should create the issue with the other items given, if it doesn't its probably another field that only task requires. If you try to create an epic you need customfield_10814 to be filled with a description and for bug you need to fill the found at location.
The syntax is correct. components should be a list.
Did you create 'JIRA' as a component in the same project?
Make sure the component name is available for that project. If you go to any ticket in the same project, the 'dropdown' in the component section should list all the available components.
Create a component for 'JIRA' . From error it seems you project doesn't have any value called 'JIRA' .
Creation of value 'JIRA' for component will solve the problem

Call python script from Jira while creating an issue

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?

Categories

Resources