root/XilinxTools/xst_io.py

Revision 20, 1.1 KB (checked in by amirh, 2 years ago)
Line 
1import os
2import subprocess
3import sys
4from threading import Thread
5
6
7class Timeout(Thread):
8    run = True
9    runs = 1
10    run_forever = 0
11    timeout = 0
12    def kill(self):
13        self.run = False
14    def set_runs(self, runs):
15        self.runs = runs
16    def set_run_forever(self):
17        self.run_forever = 1
18    def set_timeout(self,x):
19        self.timeout = x
20    def run(self):
21        while self.runs > 0 and self.run:
22            Thread.run(self)
23            if(self.timeout):
24                time.sleep(self.timeout)
25            self.runs = self.runs + self.run_forever - 1
26
27xst = subprocess.Popen('xst', stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
28
29
30def LogPrint(Port,File):
31    ln = Port.readline()
32    print ln
33    File.write(ln)
34
35logfile = open('logfile','w')
36
37xst_io = Timeout(target=LogPrint, args=[xst.stdout,logfile])
38xst_io.set_run_forever()
39xst_io.start()
40xst.stdin.write('help -arch virtex5 -command run\n')
41
42##
43##xst_io.kill()
44##
45##xst.stdin.write('quit\n')
46##
47##logfile.close()
Note: See TracBrowser for help on using the browser.