-
Notifications
You must be signed in to change notification settings - Fork 0
/
unsettings.py
80 lines (72 loc) · 2.42 KB
/
unsettings.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from __future__ import print_function
import textwrap
import yaml
import click
@click.command()
@click.option("-u", "--user",
help = "Last name of investigator",
type = str,
prompt = True)
@click.option("-e", "--experiment",
help = "Name of experiment",
type = str,
prompt = True)
@click.option("-i", "--interval",
help = "Interval between scans (mins)",
type = click.IntRange(1, 2880),
prompt = True,
default = 30)
@click.option("-n", "--nscans",
help = "Total number of scans",
type=click.IntRange(0, 9999),
prompt = True,
default=1)
@click.argument("outfile",
type=click.File("w"),
default="-")
def setrun(user, experiment, interval, nscans, outfile):
"""Write run settings to a config file (stdout).
"""
rdict = {"run":
{"user": user,
"experiment": experiment,
"interval": int(interval),
"nscans": int(nscans)}}
yaml.safe_dump(rdict, outfile,
default_flow_style = False,
encoding = "utf-8")
@click.command()
@click.option("-m", "--mode",
help = 'Scan mode',
type = click.Choice(["Gray","Color"]),
prompt = True,
default = "Gray")
@click.option("-s", "--source",
help = 'Scan source',
type = click.Choice(["TPU8x10", "Flatbed"]),
prompt = True,
default = "TPU8x10")
@click.option("-r", "--resolution",
help = "Scanner resolution (dpi)",
type = int,
prompt = True,
default = 300)
@click.option("-d", "--depth",
help = "Bit depth per pixel",
type=click.Choice(["8", "16"]),
prompt = True,
default="16")
@click.argument("outfile",
type=click.File('w'),
default='-')
def setscanner(mode, source, resolution, depth, outfile):
"""Write scanner settings to a config file (stdout).
"""
sdict = {"scanner":
{"mode": mode,
"source": source,
"resolution": int(resolution),
"depth": int(depth)}}
yaml.safe_dump(sdict, outfile,
default_flow_style = False,
encoding = "utf-8")