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