top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to read a make file in python

0 votes
487 views

How to read/load the cmake file in python and access its elements. I have a scenario, where i need to load the make file and access its elements. I have tried reading the make file as text file and parsing it,but its not the ideal solution. Please let me know how to load the .mk file and access its elements in python.

posted Jul 22, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

0 votes

First, just what do you mean by "make file"? You refer to cmake, make, and .mk in three places in your message. How about a link to the actual tool you're interested in? And a brief list of the other tools you're
using it with.

Is this it?
http://www.cmake.org/

Once we're talking about the same tool, then the question is what "elements" are you interested in? If your cmake is anything like the traditional make program, the format is deceptively simple, and enormously complex in usage.

But I suspect that your cmake has very little to do with Unix make tools. The cmake that I gave the link for uses a CMakeLists file, which looks nothing like a makefile.

answer Jul 23, 2013 by anonymous
0 votes

Take a look at pymake:

"make.py (and the pymake modules that support it) are an implementation of the make tool which are mostly compatible with makefiles written for GNU make."

http://hg.mozilla.org/users/bsmedberg_mozilla.com/pymake/

There is a parser.py file which might be useful to you.

answer Jul 23, 2013 by anonymous
Similar Questions
+1 vote

I use scapy for MGCP. I started off with reading a .pcap file with MGCP packets.

For example:

from scapy.all import *
from scapy.utils import *
from scapy.layers.mgcp import *

mgcp_pkts = rdpcap("my-mgcp-capture.pcap")

However, rdpcap() is returning all MGCP packets as UDP packets. The output is something like:

All 262 UDP packets are actually MGCP packets. 

I would have thought rdpcap() will understand MGCP packet format.

Would appreciate help on how I can make scapy read MGCP packets from a .pcap file.

+2 votes

Is there a better way to do that:

def Read_CSV_File(filename):
 file = open(filename, "r")
 reader = csv.DictReader(file)
 line = 1
 for row in reader:
 if line < 6:
 reader.next()
 line++
# process the CSV
+1 vote

With Mozrepl addon in Firefox and Python I do:

> import telnetlib
> tn = telnetlib.Telnet(r'127.0.0.1', 4242, 5)
> tn.read_eager()
'nWelcome to MozRepl.nn - If you get stuck at the "'
> tn.read_until("repl> ")
...snip...
> tn.write(r'alert(window.content.location.href)'+"n")

and I get an alert box with the URL of the active tab.

But how do I read that URL into a python variable? Something like tn.write(r';var zz = window.content.location.href'+ "n") but that doesn't get it into python.

+3 votes

I have a python script that is currently run from cron. We want to make it into a service so it can be controlled with service start/stop/restart.
Can anyone point me at site that has instructions on how to do this?

...