forked from getodk/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathss.py
More file actions
executable file
·38 lines (32 loc) · 1.15 KB
/
ss.py
File metadata and controls
executable file
·38 lines (32 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
import os
import subprocess
import sys
def ensure_dir(file_path):
directory = os.path.dirname(file_path)
if not os.path.exists(directory):
os.makedirs(directory)
def screencap():
return subprocess.check_output("adb exec-out screencap -p", shell=True)
def save_screencap(cap, filename):
with open(filename, 'wb') as f:
f.write(cap)
if __name__ == "__main__":
short_filename = sys.argv[1]
filename = 'img/' + short_filename + '.png'
ensure_dir(filename)
save_screencap(screencap(), filename)
if sys.argv[2] != '-s':
print("Insert image into doc with:")
print(".. image:: /img/" + short_filename + ".*")
print(" :alt: Alt text here. Be sure to add alt text.")
print("")
print("")
print("Use the figure directive to add a caption:")
print(".. figure:: /img/" + short_filename + ".*")
print(" :alt: Alt text here. Be sure to add alt text.")
print("")
print(" The caption is here.")
print("")
print("")
print("See http://docs.opendatakit.org/contributing/#images-and-figures for more details.")