ATLAS Offline Software
MuonRecRTT_alleps2gif.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4 
5 from __future__ import print_function
6 
7 import os
8 import sys
9 
10 # --------- Function definition --------- #
11 
12 def alleps2gif(setupok,keepeps=True,tareps=True,tardir="MuonRecRTT_epsimages"):
13 
14  if not setupok:
15  print ("Usage: " + sys.argv[0] + " [directory]")
16  return
17 
18  old = ".eps"
19  new = ".gif"
20 
21  nofiles = True
22 
23  for epsname in os.listdir("."):
24  if epsname.count(old):
25  nofiles = False
26  gifname = epsname.replace(old,new)
27  commands = [ "pstopnm -ppm -xborder 0 -yborder 0 -portrait -xsize=1000 " + epsname ,
28  "ppmtogif " + epsname + "001.ppm > " + gifname ,
29  "rm " + epsname + "001.ppm" ]
30  if not keepeps:
31  commands.append("rm " + epsname)
32  for command in commands:
33  print ("Running: " + command)
34  os.system(command)
35 
36  if keepeps and tareps:
37  commands = [ "mkdir " + tardir ,
38  "mv *" + old + " " + tardir ,
39  "tar -czf " + tardir + ".tar.gz " + tardir ,
40  "rm -rf " + tardir ]
41  for command in commands:
42  print ("Running: " + command)
43  os.system(command)
44 
45  if nofiles:
46  print ("No " + old + " files in directory.")
47 
48 # -------- Start of running is here ------- #
49 
50 setupok = True
51 
52 if len(sys.argv) > 1:
53  if len(sys.argv) > 2:
54  setupok = False
55  else:
56  print ("Changing to directory: " + sys.argv[1])
57  try:
58  os.chdir(sys.argv[1])
59  except:
60  print ("Move to directory " + sys.argv[1] + " failed.")
61  setupok = False
62 else:
63  print ("Running in current directory.")
64 
65 alleps2gif(setupok)
66 
67 # sprintf(comm1,"%s %s","pstopnm -ppm -xborder 0 -yborder 0 -portrait",epsname);
68 # sprintf(comm2,"%s %s%s %s","ppmtogif",epsname,"001.ppm >",gifname);
69 # sprintf(comm3,"rm %s",epsname);
70 # sprintf(comm4,"rm %s001.ppm",epsname);
71 
MuonRecRTT_alleps2gif.alleps2gif
def alleps2gif(setupok, keepeps=True, tareps=True, tardir="MuonRecRTT_epsimages")
Definition: MuonRecRTT_alleps2gif.py:12