123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #!/usr/bin/env python
- """
- Perform demented installation tasks with blind rodents.
- """
- import subprocess, os, time, xvfbwrapper, shutil, argparse
- screencap_dir = "/cryptech-builder"
- screencap_file = os.path.join(screencap_dir, "Xvfb_screen0")
- def snooze(how_long = 15):
- time.sleep(how_long)
- def click(*coordinates):
- assert len(coordinates) in (0, 2)
- if coordinates:
- subprocess.check_call(("ratpoison", "-c", "ratwarp {:d} {:d}".format(*coordinates)))
- shutil.copy(screencap_file, "{}.{:f}.xwd".format(screencap_file, time.time()))
- subprocess.check_call(("ratpoison", "-c", "ratclick"))
- with xvfbwrapper.Xvfb(fbdir = screencap_dir):
- print("DISPLAY={}".format(os.getenv("DISPLAY")))
- print("Starting rodent-free window manager")
- rat = subprocess.Popen(("ratpoison",))
- time.sleep(0.5)
- snooze()
- print("Starting XiLinx installer")
- xsetup = subprocess.Popen(("./xsetup",), cwd = os.getenv("XILINX_PKGDIR"))
- snooze()
- print("First screen")
- click(650, 610)
- snooze()
- print("Second screen")
- click(250, 420)
- click(250, 444)
- click(650, 610)
- snooze()
- print("Third screen")
- click(600, 560)
- click(650, 610)
- snooze()
- print("Fourth screen")
- click(300, 100)
- click(650, 610)
- for ith in ("Fifth", "Sixth", "Seventh"):
- snooze()
- print(ith + " screen")
- click()
- print("Waiting half an hour for XiLinx installer to run, ^C if you get bored")
- snooze(1800)
- # In theory we could use visgrep to check for the "finish" button.
- # In practice ... this is such a kludge, what's one more, let's just
- # try blindly clicking where the finish button should be and see
- # if that results in a usable image.
- print("Blindly clicking where finish button should be")
- click(720, 610)
- print("xsetup exited with status {}".format(xsetup.wait()))
- snooze()
- print("Starting XiLinx license manager")
- xlcm = subprocess.Popen(". /opt/Xilinx/14.7/ISE_DS/settings64.sh; /opt/Xilinx/14.7/ISE_DS/common/bin/lin64/xlcm -manage",
- shell = True, cwd = "/home/builder", env = dict(os.environ, USER = "builder", HOME = "/home/builder"))
- snooze()
- print("First screen")
- click(100, 116)
- snooze()
- print("Second screen")
- click(220, 170)
- click(680, 490)
- snooze()
- print("Third screen")
- click(400, 360)
- click(750, 650)
- print("xlcm exited with status {}".format(xlcm.wait()))
- print("Shutting down")
- subprocess.check_call(("ratpoison", "-c", "quit"))
- print("ratpoison exited with status {}".format(rat.wait()))
|