I need to set the anti-aliasing parameters for map services via python. Not having much luck in locating on how to configure this.
I have tried looking into the.sddraft file as mentioned in the documentation: https://desktop.arcgis.com/en/arcmap/10.6/analyze/arcpy-mapping/createmapsddraft.htm
However, when I open the .sddraft file as a xml, I cannot find the textAntiAliasingMode or AntiAliasingMode parameter in the file. Therefore I cannot use xml.dom.minidom to update it.
Any ideas??
Related
I have a problem. Let's say I have a website (e.g. www.google.com). Is there any way to create a file with a .url extension linking to this website in python? (I am currently looking for a flat, and I am trying to save shortcuts on my hard drive only to apartment offers posted online matching my expectations ) I've tried to use the os and requests module to create such files, but with no success. I would really appreciate the help. (I am using python 3.9.6 on Windows 10)
This is pretty straightforward. I had no idea what .URL files were before seeing this post, so I decided to drag its URL to my desktop. It created a file with the following contents which I viewed in Notepad:
[InternetShortcut]
URL=https://stackoverflow.com/questions/68304057/internet-shortcut-in-python
So, you just need to write out the same thing via Python, except replace the URL with the one you want:
test_url = r'https://www.google.com/'
with open('Google.url','w') as f:
f.write(f"""[InternetShortcut]
URL={test_url}
""")
With regards to your current attempts:
I've tried to use os and requests module to create such file
It's not clear what you're using requests or os for, since you didn't provide a Minimal Reproduceable Example of what you'd tried so far; so, if there's a more complex element to this that you didn't specify, such as automatically generating the file while you're in your browser, or something like that, then you need to update your question to include all of your requirements.
I have a couple of graphs that need to be shown on a local website, they're made with MPLD3, and I used the save_html option. However, I've just been told that the graphs need to be able to be viewed offline, so I wanted to know if there was a way to do this without mpld3.show(), because I need the graphs embedded in the website.
Please elaborate if possible what you mean by "local website". It sounds like you have an index.html file on your hard drive that you're rendering in a browser.
If that's the case and you want this to work with no internet connection, then it's likely you'll have to embed the D3 javascript dependency and the mpld3 javascript dependency into the html file after you save it to the a file. I think the default behavior is to retrieve those libraries from a cdn rather than embedding them in full.
Another option would be to try using the fig_to_html() function kwargs d3_url= and mpld3_url= to set the paths to your locally stored D3 and mpld3 libraries using a "file://" prefix rather than the "https://" prefix (again, this just avoids loading the dependencies via cdn).
Question in the title. Using the remote python API of v-rep, I am able to get images and control motor properties of robots, but I cannot find any way to get the coordinates of a path object that was made with the path planning functionality in v-rep. I would like to get them as an array in my external python script.
I have found that there is no remote API functions dedicated to path objects, but there might be a more generic function that could be used for this.
A workaround provided by the developers on the v-rep forum as there does not seem to be a straightforward way to do this:
http://www.forum.coppeliarobotics.com/viewtopic.php?f=9&t=7095&p=28040#p28040
First sample the path coordinates with simGetPathPosition, inside of a script function. Then call that script function from the python remote Api client, via simxCallScriptFunction.
Use this line of code to extract the coordinates errorCode, sensor_handle = vrep.simxGetObjectHandle(clientID, 'GPS', vrep.simx_opmode_oneshot_wait)
I'm looking to store some individual settings to each user's computer. Things like preferences and a license key. From what I know, saving to the registry could be one possibility. However, that won't work on Mac.
One of the easy but not so proper techniques are just saving it to a settings.txt file and reading that on load.
Is there a proper way to save this kind of data? I'm hoping to use my wx app on Windows and Mac.
There is no proper way. Use whatever works best for your particular scenario. Some common ways for storing user data include:
Text files (e.g. Windows INI, cfg files)
binary files (sometimes compressed)
Windows registry
system environment variables
online profiles
There's nothing wrong with using text files. A lot of proper applications uses them exactly for the reason that they are easy to implement, and additionally human readable. The only thing you need to worry about is to make sure you have some form of error handling in place, in case the user decides to replace you config file content with some rubbish.
Take a look at Data Persistence on python docs. One option a you said could be persist them to a simple text file. Or you can save your data using some serialization format as pickle (see previous link) or json but it will be pretty ineficient if you have several keys and values or it will be too complex.
Also, you could save user preferences in an .ini file using python's ConfigParser module as show in this SO answer.
Finally, you can use a database like sqlite3 which is simpler to handle from your code in order to save and retrieve preferences.
First of all, I agree that this might sound like a question which has already been asked many times in the past. However I couldn't find any answer that was relevant to me in the similar questions so I'll try to be more specific.
I would need to transform PPTX/DOCX files into PDF using Python but I don't have any experience in file format conversion. I have been looking in many places/forums/websites, read a lot of documentation and came across some useful libraries (python-pptx and pyPdf mainly), but I still don't know where to start.
When looking on the Internet, I can see many websites that offer file format conversions as a paying service, even with advanced API's: submit a file via POST and get the transformed PDF file in return. This could work for me, but I am really interested in writing myself the code that does the conversion work from OOXML to PDF.
How would you start doing this? Or is it just impossible on my own?
Thanks for your help!
After some research and with the help of python-pptx's creator, I was able to write to the PowerPoint COM interface using a Virtual Machine.
In case someone reads this thread, this is how I managed to get this done:
- Setup a VM with Microsoft Windows/Office installed on it ;
- Install Python, Django and win32com libraries on the VM.
The files are sent locally from the original Django project to the virtual machine (which are on the same network) through a simple POST request. The file is converted on the VM using win32com.client (which is just a simple call to the win32com.client library) and then sent back as a response to the original Django view, which in turn processes the response.
Note: it took me some time to realize I needed to use the #csrf_exempt decorator for this setup to work.