SAS or Python Extracting Map for Directions as Picture - python

I would like to use SAS or Python to achieve this.
I have multiple points that I would like to map out using mapquest/maps.google/maps.bing, and then download a screenshot of the map on to my C: drive.
This would not be a one time thing. I would need it to download multiple maps (Have a map for route within Chicago, then another for a route within Pittsburgh).
I was hoping there may be a module within Python that enables this.
Also, on a side note, is there a way to call Python scripts from within a SAS program? Could I possibly embed it in to a VBA script which is then called from SAS?

You should be able to do the lot from SAS if the APIs for Google/MapQuest/Bing all support URI requests...
In SAS you can make the API request and retrieve and process the data. An example is shown here.
I'm not sure what the API request is going to return or how you would then use/interpret that. If it's standard XML use the SAS XML mapper. If it's anything else (ie. Image/MIME data) then things may get trickier.

The family of Google Maps APIs lets you call down various services from any language that will let you send a URL request. The Static API might be of special interest to you, though I'm not sure if you can overlay directions, or how.
To do this in Python, you could use urllib for interacting with the API; there's also pymaps.

Related

trying to create script that scan for secrets in python code

As part of our CI/CD we want to add some check to run code on python files and check if there are some secrets in code (like API, passwords etc.).
I saw only programs that do this, and I want to create a Python script that does it.
Does anyone have some suggestion or example for this?
I'm not sure it exactly what you look for but you can use GitGuardian API,
The GitGuardian API puts at your fingertips the power to detect more
than 200 types of secrets in any text content, as well as other
potential security vulnerabilities.
py-gitguardian can be used to create integrations to scan various data
sources, from your workstation's filesystem to your favorite chat
application.
You can check API details here with all the response codes and expected structures on each method.
just take a look GitGuardian/py-gitguardian Github repository,
You can also check this Youtube video that will help you implement this.
Good luck.

How do I access and use AWS config/credential information in my boto3/python app on mac?

I'm looking to use information like my mfa_serial provided from the ~/.aws/config file in my code.
The only way I've been able to figure out how to access it programmatically is by creating something like:
import boto3
foo = boto3
mfa_serial = foo.DEFAULT_SESSION._session.full_config['profiles']['default']['mfa_serial']
print(mfa_serial)
I feel like there's got to be a better way to access this info, I've read through the documentation and they talk about using environmental variables, but I'm not experienced enough as a programmer to really know intuitively what that means and no one has really explained to me how to use environmental variables in Python. I'm googling it as we speak, but I feel like in terms of AWS I might be missing some trick to it. All the docs just say something like
export SOME_ENV_VAR='some value you want'
but I have no idea what that means, or where to put it in my code, or if it even goes into my code, or what that line even means.
I've used environmental vars in C# with .NET and ASP.NET, and .NET Core, so I'm somewhat familiar with using a .env file, but not sure how it works with Python.
Overall I'm looking to validate MFA. Basically I'm working on building an app that identifies which instances of which services are using which roles, I'm logging in as my AWS user, using the tokens, using boto3 to create an STS client and get_session_token() but I need the mfa_serial, and a way to put in the MFA token, as part of the input for the get_session_token() call

Accessing Enovia's python interface from Excel / VBA?

We are using software called Enovia.
I would like to query Enovia from inside Excel / VBA.
After some search, Enovia seems to have a programming interface called Abaqus.
http://www.3ds.com/products-services/simulia/services/training-courses/course-descriptions/introduction-to-the-abaqus-scripting-interface/
I would like to access this interface in VBA directly but I didn't find anything to that effect.
I found two projects that might allow Excel/VBA to talk to python components or at least to python scripts.
They are as follows
Python For Excel
http://opentradingsystem.com/PythonForExcel/main.html
And the discontinued excelpython
github.com/ericremoreynolds/excelpython
which became integrated in xlwings
xlwings.org
I am not familiar with python nor these two projects. I'm not sure if they will allow me to do what I want.
I'm ok with learning some python to do this but my main program and user interface is in excel.
I figure I could make some simple python scripts then call them through the python interpreter from excel with shellexecute but that is not a very elegant solution I think.
Any advice welcomed
thanks !
Enovia uses the MQL language for scripting. There are some guides available, such as http://emdros.org/MQL-Programmers-Guide.pdf
I would recommend some training such as http://www.techniatranscat.com/services/education/mql-and-tcl-intro as this doesnt seem to be a very common language.
Not to be confused with the financial trading language MQL4/MQL5 from MetaQuotes Software Corp.
ENOVIA does not have a Python programming interface.
Abaqus is a FEA simulation software which can be scripted with its own Python programming interface.
ENOVIA though, is a PLM software solution. They are different software for completely different applications. As programming interfaces you may look at maybe this
In short, you may need to contact your Dassault Systemes local support team to point you in the right direction.
Using tcl and mql you can solve the problem
TCL |
MQL
Latest Enovia version 3DEXPERIENCE support Rest based webservices. you can create a rest API in enovia and can call rest service using vb script in excel.
3DEXPERIENCE Enovia Rest webservice Framework
Above mentioned Rest framework may not be available with 2014X version. You have to try SOAP based service or JAX-RS.
Option 1
Enovia is java based application and doesn't support VBA ADK to directly work with backend data. However webservice can be used communicate between applications of different platforms or managed by different programming ADK.
For this you need to create your own service (REST/SOAP). For this you will need server access and first you have to write some java code (Rest/SOAP service) and update the class/jar into 2014 server (tomcat).
Then you can make use of that service in to your vba function.
Again you have to decide the kind of data whether xml or json it is separate topic.
Option 2
As I told earlier Enovia is Java based application, It provides JAVA ADK to extend its functionality.
Sample code shows how you can get the context and work with Enovia ADK.
matrix.db.Context ctx = new matrix.db.Context("http://myserver-nocas:8080/enovia");
ctx.setUser("Test Everything");
ctx.setPassword("");
ctx.connect();
System.out.println("Is context set "+ctx.isConnected());
As you mentioned you are currently using 3DEXPERIENCE then 3DPassport might block above URL method connection, So you need to pass NO-CAS URL.
You can get the context by running above java code from your local eclipse. Using this ADK you can also call MQL queries and work seamlessly.
import com.matrixone.apps.domain.util.MqlUtil;
String strPartFamily = MqlUtil.mqlCommand(ctx,"temp query bus Part * * select attribute[Length]");
But again this is java based solution and not VBA.
Finally 3DEXPERIENCE provides MQL console in server, to play around with all the data using SQL like queries in more developer friendly manner. Enovia also provides web based MQL console but you need to have some license for that (Administrator should be having access).
Use TCL to go through Excel sheet, it is very easy. Use "/t" to separate data.

Google Street View coordinate data python

I need to know which are the real coordinates for google street view for a GIVEN pair of coordinates using python.
In the google maps Python API there is not how to access to this information. (There is how to in the Javascript API)
I found a non-documented API that returns what I need, but since it seems to be illegal to use undocumented API's to get this information, is there another possibility without changing my programming language? Maybe connecting the Javascript with Python but I don't have idea how to make this.
Thank you!
The best solution is to use the command below to get the closest road:
google.maps.StreetViewService().getPanoramaByLocation()
And then use it to retrieve the image. Unfortunately, I don't know how to do that in Python...

Betfair Python API

My answer is quite specific to the Betfair API however I would like to know how to use more APIs in general. I'm quite new to this sort of thing so don't really know how it works. I've just downloaded this package: https://github.com/jmcarp/betfair.py
My question is, how am I supposed to know the functions that come associated with it? How am I supposed to be able to know how to pull the data that I want from any given website without having any resource describing the functionality of the API?
These library is only a binding (with several errors) to Betfair APIs.
You can find documentation about this API, and therefore about this library, in Developer's web.
If you're interested in how to use Betfair APIs in Python you can take a look at Betfair's code samples.

Categories