Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I am installing Cisco ASA Firewall for my customer at several locations. The basic ASA configuration for all the locations is the same with a deviation of certain things like Interface IP addresses, Routing next hops, etc.
For every location I have an excel sheet with all the variables.
I know basic Python. The question is : is it possible to write a script in python which will read the variables in the Excel Sheet and generate the configuration for ASA?
Moreover could someone recommend a source to learn scripting targeted for networking or such an automation task? (Simply googling led me to many confusing options and hence the question here)
I suggest you use templating engine such as jinja2 along with python.
(https://github.com/jedelman8/interop-nyc-2014.git)
(http://keepingitclassless.net/2014/03/network-config-templates-jinja2/)
Or you can use simple Ansible tool along with Jinja2 templates to generate configs. (No need for programming skills)
(https://sreeninet.wordpress.com/2014/09/28/ansible-for-networking-automation-part-1/)
(https://sreeninet.wordpress.com/2014/09/28/ansible-for-network-automation-part-2/)
(https://sreeninet.wordpress.com/2014/09/28/network-device-configuration-using-templates-with-jinja2-and-yaml/)
(http://jedelman.com/home/ansible-for-networking/)
I would also suggest to look at a very good library "netmiko" for ssh connection in future and push, pull config (https://github.com/ktbyers/netmiko/tree/master/examples)
All above options can work for you. See below examples. I am a Network professional myself and found these useful.
This is pretty easily done with Python, but will take a bit of learning.
Depending on the format of the Excel file, I would recommend OpenPyXL, or XLRD.
This will also depend on the configuration format you are wanting to output. If it's a JSON Config file, you can simple use the built-in json module. Otherwise, there are a variety of other modules out there for things like CSV, etc.
One warning, however. If you hard-code all of your Excel columns/positions within your code, you could be in for a world of hurt in the event that the columns change.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I really am lost.
I've written a python script which takes two files, converts one to the same format as the second and outputs the differences.
I now need to create some kind of GUI?
I'm thinking a relatively simple HTML page which allows users to click on two separate boxes to upload each of the files and then submit them - resulting in the output being offered as file which the user can download to the PC.
Any help of direction would be really appreciated. It's only really a guess that HTML will be my best/simplest choice. Working from the command line isn't really an option I can go with. The PC that this will sit on will not have internet access. I intend to have this installed on the PC as an application.
I accept I'll need to make some changes to my Python code. Posted this here as I'm not sure Python questions would have been the best place but I'll move it if suggested.
Please, any help at all will be useful. First timer
This is not a kind of answer that normally gets a reply on StackOverflow because it is much too broad / subjective.
Given the fact that you are quite new I would like to provide a solution anyway that will allow you to build a GUI quite easily like EasyGUI.
A very easy example:
import easygui
easygui.msgbox('This is a basic message box.', 'Title Goes Here')
Other possibilities (less customizable but arguably easier) are Wooey (automatic web interface generation for your script) and Gooey (automatic GUI generation for your script.
Please, for next time, remember to always provide a Minimal Reproducible Example and read https://stackoverflow.com/help/how-to-ask
I don't suggest you use the Django Framework for such a small application.
You should definitely use Flask for this. Flask is more lightweight
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
i have a mysql database that i'd like to query. i would like to format the results a certain way, then turn it into a pdf. in the past, i used PHP and FPDF, while it worked, it was a pain and tedious. i don't think PHP can handle this sort of thing. i don't have much experience in python or ruby but this would be a great project to do in either language so i can get more familiar. it doesn't have to be web based. it can be desktop script that i could run with a cron or manually. hope someone can point me to some resources. thanks.
In Ruby you have a number of options for your PDF authoring, and your DB management is very easy if you use the ActiveRecord library (comes with Rails) or Sequel to read or write data.
Complete and heavy duty PDF authoring can be done using Prawn... it requires some studying, but it's an amazing library.
You can also create HTML web pages and convert them into PDF using the wicked_pdf gem, which is quite simple to use.
Or, you can combine it all, or write simple PDF's with simple tables and text using the combine_pdf, which is as easy as it gets and also allows you to use PDF templates (so you can have a well designed template and just add the text you need).
I love Ruby and I think it's very easy to learn. Plus, it has more applications than just web programming - there's even a project called RubyMotion which lets you program native applications for iOS and Android using Ruby!
I'm sure you'll love Ruby.
In Python, you can use pyPdf to create PDF files. As for the querying a mySQL DB, you can use mySQLdb. Installing it is slightly harder than other modules, but once you have done so, it's just like any other sql package. Hope it helped.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I'm writing some code that uses Python to shuffle data around between Excel, CSV and SQLite.
It occurs to me that this may be of use to others, in which case I should generalise it, wrap it up as a library and release it.
I don't want to reinvent wheels, though. Before I embark on this magical adventure, is there already a (python?) library that:
Exports SQL databases to CSV or Excel. (Relatively easy.)
Imports CSV/Excel files into SQL, sniffing the data to automatically create tables with columns of the correct types. (A bit more interesting.)
Please provide links to any libraries that already exist (python or otherwise.)
For the SQLite/CSV interactions, I am the author of a wrapper known as APSW. It provides deeper integration between Python and SQLite. One of the components is a shell that can be used interactively/scripted, as well as programmatically via Python. It can produce CSV from your database.
More interestingly there is also an .autoimport command that given a CSV file with headers will import it into SQLite. It automatically works out the separators (tab or commas), creates the table and correctly determines the data formats as SQLite's typing is different. For example it won't mess up phone numbers and it can determine what are dates even working out if they are in US, Japanese or standard formats.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
Improve this question
Can I program 8051 using Python?
I'm not getting any of the to program 8051 in python environment.
If anybody knows, please help me.
There is Python-on-a-Chip, but note its "disclaimer":
"The PyMite VM DOES NOT HAVE:
A built-in compiler
Any of Python's libraries (no batteries included)
A ready-to-go solution for the beginner (you need to know C and how to work with microcontrollers)"
Thus, if the questioner's goal for python was to avoid dealing with the strangeness of the 8051, this may not help.
In particular, the 8051 is a "Harvard" style architecture, with separate RAM and ROM codespaces, and with very limited internal RAM, and larger external RAM that can be accessed only via loading the special DPTR register and then reading or writing indirectly, plus there's no external RAM stack support, nor intrinsic support for stack-based variables. Thus, most "general purpose" high-level languages need lots of customization and reworking to run on the 8051.
A good 8051-specific C-compiler can hide many of these low-level details, but you wind up burning lots of cycles to do things that are single instructions on desktop CPUs and even on most newer embedded controller architectures, and even if you can live with that level of in-efficiency, you still need to sort out the various memory spaces and other specifics.
So, getting Python to work on the 8051 is likely to be a challenging project for someone deeply familiar with its quirky architecture. If your goal is to dump a python onto the 8051 to avoid needing to learn these quirks, I'm not sure that is possible. (But, I suppose the C compilers keep getting better and better...)
Python-on-a-Chip looks about as close as you're going to get. It can run on some things that are just a bit beefier than the 8051.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Is there any production ready open source twitter clones written in Ruby or Python ?
I am more interested in feature rich implementations, not just bare bones twitter like messages (e.g.: APIs, FBconnect, Notifications, etc)
Thanks !
I know of twissandra which is an open source clone. Of course I doubt it meets your need of feature rich implementations.
http://github.com/rnielsen/twetter
From their readme:
Twetter is an implementation of the twitter.com API, designed for use in situations where internet access is not available but a large number of people have twitter clients and want to tell each other what they are doing, for example a RailsCamp, where it was first developed.
The current goal is to have it work with as many third party twitter clients as possible. It has currently been tested with Twitterific, TwitterFox, and Spaz on OSX.
The following open source alternative to twitter : http://identi.ca/ is written using the the software http://status.net/ . It looks like it is written in PHP too.
Also there is http://code.google.com/p/jaikuengine/ which is a microblogging platform for google app engine. This should serve as an example for python implementation.
Also look at http://www.typepad.com/go/motion/
Found two relevant projects:
http://github.com/insoshi/insoshi
http://github.com/dmitryame/echowaves/wiki
Sadly both appear discontinued