aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2019-02-14 00:29:55 +0000
committerRob Austein <sra@hactrn.net>2019-02-14 00:29:55 +0000
commit6cf7d84730b306de4bff43699f18e72dec39c3b2 (patch)
tree45c060cd7bd2cd694c157887756fdad33875b5d9
parent0ca9d2581042b11ff2fb04e9095f033a6edf74a2 (diff)
Consolidate voodoo
-rw-r--r--.gitignore2
-rwxr-xr-xratinox128
2 files changed, 129 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 1bd43b7..c215d4e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
framebuf/Xvfb_screen0
-screenlog.*
+*.log
*.stamp
Xilinx_ISE_DS_Lin_14.7_1015_1.tar
Xilinx.lic
diff --git a/ratinox b/ratinox
new file mode 100755
index 0000000..86667a0
--- /dev/null
+++ b/ratinox
@@ -0,0 +1,128 @@
+#!/usr/bin/env python
+
+"""
+Perform demented tasks with blind rodents.
+"""
+
+import subprocess, os, time, xvfbwrapper, shutil, argparse
+
+class Ratinox(xvfbwrapper.Xvfb):
+
+ xvfb_screen_name = "Xvfb_screen0"
+
+ def __init__(self, **kwargs):
+ if kwargs.pop("screencap", True) and "fbdir" in kwargs:
+ self.screencap_file = os.path.join(kwargs["fbdir"], xvfb_screen_name)
+ else:
+ self.screencap_file = None
+ super(Ratinox, self).__init__(**kwargs)
+
+ def __enter__(self):
+ result = super(Ratinox, self).__enter__()
+ self.wm = subprocess.Popen(("ratpoison",))
+ time.sleep(0.5)
+ return result
+
+ def __exit__(self, exc_type, exc_val, exc_tb):
+ self.rat("quit")
+ self.wm.wait()
+ self.wm = None
+ super(Ratinox, self).__exit__(exc_type, exc_val, exc_tb)
+
+ def click(self, *coordinates):
+ assert len(coordinates) in (0, 2)
+ if coordinates:
+ subproccess.check_call(("ratpoison", "-c", "ratwarp {:d} {:d}".format(*coordinates)))
+ if self.screencap_file:
+ shutil.copy(self.screencap_file, "{}.{}".format(self.screencap_file, time.time()))
+ subproccess.check_call(("ratpoison", "-c", "ratclick"))
+
+def snooze(how_long = 15):
+ time.sleep(how_long)
+
+def installer():
+
+ with Ratinox(fbdir = "/framebuf") as rat:
+ print("DISPLAY={}".format(os.getenv("DISPLAY")))
+
+ snooze()
+ print("Starting XiLinx installer")
+ xsetup = subprocess.Popen(("./xsetup",), cwd = "/xilinx-unpack/Xilinx_ISE_DS_Lin_14.7_1015_1")
+
+ snooze()
+ print("First screen")
+ rat.click(650, 610)
+
+ snooze()
+ print("Second screen")
+ rat.click(250, 420)
+ rat.click(250, 444)
+ rat.click(650, 610)
+
+ snooze()
+ print("Third screen")
+ rat.click(600, 560)
+ rat.click(650, 610)
+
+ snooze()
+ print("Fourth screen")
+ rat.click(300, 100)
+ rat.click(650, 610)
+
+ for ith in ("Fifth", "Sixth", "Seventh"):
+ snooze()
+ print(ith + " screen")
+ rat.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")
+ rat.click(720, 610)
+
+ print("xsetup exited with status {}".format(xsetup.wait()))
+
+def licenser():
+
+ with Ratinox(fbdir = "/framebuf") as rat:
+ print("DISPLAY={}".format(os.getenv("DISPLAY")))
+
+ snooze()
+ print("Starting XiLinx license manager")
+ xlcm = ". /opt/Xilinx/14.7/ISE_DS/settings64.sh; /opt/Xilinx/14.7/ISE_DS/common/bin/lin64/xlcm -manage"
+ xlcm = subprocess.Popen(xlcm, shell = True)
+
+ snooze()
+ print("First screen")
+ rat.click(100, 116)
+
+ snooze()
+ print("Second screen")
+ rat.click(220, 170)
+ rat.click(680, 490)
+
+ snooze()
+ print("Third screen")
+ rat.click(400, 360)
+ rat.click(750, 650)
+
+ print("xlcm exited with status {}".format(xlcm.wait()))
+
+def main():
+
+ dispatch = {"ise-install" : installer,
+ "license-user" : licenser }
+
+ ap = argparse.ArgumentParser(description = __doc__)
+ ap.add_argument("command", choices = tuple(sorted(dispatch)))
+ args = ap.parse_args()
+
+ dispatch[args.command]
+
+if __name__ == "__main__":
+ main()