annotate Resources/CMake/LinuxStandardBaseUic.py @ 1357:0dc5b8a4b3a0 broker

hgignore
author Benjamin Golinvaux <bgo@osimis.io>
date Wed, 15 Apr 2020 15:23:07 +0200
parents 95939fa925f6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1041
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 import subprocess
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 import sys
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 if len(sys.argv) <= 1:
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 sys.stderr.write('Please provide arguments for uic\n')
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 sys.exit(-1)
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 path = ''
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 pos = 1
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 while pos < len(sys.argv):
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 if sys.argv[pos].startswith('-'):
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 pos += 2
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 else:
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 path = sys.argv[pos]
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 break
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 if len(path) == 0:
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 sys.stderr.write('Unable to find the input file in the arguments to uic\n')
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 sys.exit(-1)
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 with open(path, 'r') as f:
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 lines = f.read().split('\n')
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 if (len(lines) > 1 and
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 lines[0].startswith('<?')):
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 content = '\n'.join(lines[1:])
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 else:
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 content = '\n'.join(lines)
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 # Remove the source file from the arguments
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 args = sys.argv[1:pos] + sys.argv[pos+1:]
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 p = subprocess.Popen([ '/opt/lsb/bin/uic' ] + args,
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 stdin = subprocess.PIPE)
95939fa925f6 LinuxStandardBaseUic.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 p.communicate(input = content)