-
Notifications
You must be signed in to change notification settings - Fork 0
/
console.py
executable file
·204 lines (185 loc) · 7.5 KB
/
console.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
import sys
import click
sys.path.append('./src')
from ptpip.client import PtpIpClient
from ptpip.cli.get_device_info import GetDeviceInfoCommand
from ptpip.cli.get_device_prop_desc import GetDevicePropDescCommand
from ptpip.cli.get_device_prop_value import GetDevicePropValueCommand
from ptpip.cli.get_live_view_image import GetLiveViewImageCommand
from ptpip.cli.get_num_objects import GetNumObjectsCommand
from ptpip.cli.get_object_handles import GetObjectHandlesCommand
from ptpip.cli.get_object_info import GetObjectInfoCommand
from ptpip.cli.get_object_props_supported import GetObjectPropsSupportedCommand
from ptpip.cli.get_storage_ids import GetStorageIdsCommand
from ptpip.cli.get_storage_info import GetStorageInfoCommand
from ptpip.cli.init_capture import InitCaptureCommand
from ptpip.cli.set_device_prop_value import SetDevicePropValueCommand
@click.group()
def cli():
pass
@cli.command('device')
@click.option('--host', default=None, help='Hostname')
@click.option('--port', default=None, help='Port')
@click.option('--debug', default=False, help='Debug mode')
@click.option('--discover', default=True, help='Discover unoffically supported properties ?')
@click.option('--more', default=False, help='Discover every possible property ?')
@click.option('--report', default='d5300.html', help='Report filename')
def getDeviceInfo(host, port, debug, discover, more, report):
PtpIpClient(
GetDeviceInfoCommand(discover, more, report).run,
host = host,
port = port,
debug = debug
)
@cli.command('propdesc')
@click.option('--host', default=None, help='Hostname')
@click.option('--port', default=None, help='Port')
@click.option('--debug', default=False, help='Debug mode')
@click.option('--name', help='Property name')
@click.option('--id', help='Property id', type=int)
def getDevicePropDesc(host, port, debug, name, id):
PtpIpClient(
GetDevicePropDescCommand(name, id).run,
host = host,
port = port,
debug = debug
)
@cli.command('setprop')
@click.option('--host', default=None, help='Hostname')
@click.option('--port', default=None, help='Port')
@click.option('--debug', default=False, help='Debug mode')
@click.option('--name', help='Property name')
@click.option('--id', help='Property id', type=int)
@click.option('--typename', help='Property type name')
@click.option('--typeid', help='Property type id', type=int)
@click.option('--value', required=True, help='Property value')
def setDevicePropValue(host, port, debug, name, id, typename, typeid, value):
PtpIpClient(
SetDevicePropValueCommand(name, id, typename, typeid, value).run,
host = host,
port = port,
debug = debug
)
@cli.command('getprop')
@click.option('--host', default=None, help='Hostname')
@click.option('--port', default=None, help='Port')
@click.option('--debug', default=False, help='Debug mode')
@click.option('--name', help='Property name')
@click.option('--id', help='Property id', type=int)
@click.option('--typename', help='Property type name')
@click.option('--typeid', help='Property type id', type=int)
def getDevicePropValue(host, port, debug, name, id, typename, typeid):
PtpIpClient(
GetDevicePropValueCommand(name, id, typename, typeid).run,
host = host,
port = port,
debug = debug
)
@cli.command('capture')
@click.option('--host', default=None, help='Hostname')
@click.option('--port', default=None, help='Port')
@click.option('--debug', default=False, help='Debug mode')
@click.option('--output', default=None, help='Save image to given filepath')
def initCapture(host, port, debug, output):
PtpIpClient(
InitCaptureCommand(output).run,
host = host,
port = port,
debug = debug
)
@cli.command('storageids')
@click.option('--host', default=None, help='Hostname')
@click.option('--port', default=None, help='Port')
@click.option('--debug', default=False, help='Debug mode')
def getStorageIds(host, port, debug):
PtpIpClient(
GetStorageIdsCommand().run,
host = host,
port = port,
debug = debug
)
@cli.command('storage')
@click.option('--host', default=None, help='Hostname')
@click.option('--port', default=None, help='Port')
@click.option('--debug', default=False, help='Debug mode')
@click.option('--id', required=True, help='Storage id', type=int)
def getStorageInfo(host, port, debug, id):
PtpIpClient(
GetStorageInfoCommand(id).run,
host = host,
port = port,
debug = debug
)
@cli.command('numobjects')
@click.option('--host', default=None, help='Hostname')
@click.option('--port', default=None, help='Port')
@click.option('--debug', default=False, help='Debug mode')
@click.option('--id', required=True, help='Storage id', type=int)
@click.option('--format', help='Object format id', type=int)
@click.option('--formatname', help='Object format name')
@click.option('--handle', help='Object handle of the directory', type=int)
def getNumObjects(host, port, debug, id, format, formatname, handle):
PtpIpClient(
GetNumObjectsCommand(id, format, formatname, handle).run,
host = host,
port = port,
debug = debug
)
@cli.command('objhandles')
@click.option('--host', default=None, help='Hostname')
@click.option('--port', default=None, help='Port')
@click.option('--debug', default=False, help='Debug mode')
@click.option('--id', help='Storage id', type=int)
@click.option('--format', help='Object format id', type=int)
@click.option('--formatname', help='Object format name')
@click.option('--handle', help='Object handle of the directory', type=int)
@click.option('--all-storages', help='Search in all storages', type=bool)
@click.option('--all-formats', help='Search in all formats', type=bool)
def getObjectHandles(host, port, debug, id, format, formatname, handle, all_storages, all_formats):
PtpIpClient(
GetObjectHandlesCommand(id, format, formatname, handle, all_storages, all_formats).run,
host = host,
port = port,
debug = debug
)
@cli.command('objinfo')
@click.option('--host', default=None, help='Hostname')
@click.option('--port', default=None, help='Port')
@click.option('--debug', default=False, help='Debug mode')
@click.option('--handle', required=True, help='Object handle', type=int)
def getObjectInfo(host, port, debug, handle):
PtpIpClient(
GetObjectInfoCommand(handle).run,
host = host,
port = port,
debug = debug
)
@cli.command('formatprops')
@click.option('--host', default=None, help='Hostname')
@click.option('--port', default=None, help='Port')
@click.option('--debug', default=False, help='Debug mode')
@click.option('--id', help='Object format id', type=int)
@click.option('--name', help='Object format name')
@click.option('--names', default=False, help='Print object property names', type=bool)
def getObjectPropsSupported(host, port, debug, id, name, names):
PtpIpClient(
GetObjectPropsSupportedCommand(id, name, names).run,
host = host,
port = port,
debug = debug
)
@cli.command('liveimg')
@click.option('--host', default=None, help='Hostname')
@click.option('--port', default=None, help='Port')
@click.option('--debug', default=False, help='Debug mode')
@click.option('--output', default=None, help='Ouput filepath')
@click.option('--fps', default=None, help='Frames per second', type=float)
def getLiveViewImage(host, port, debug, output, fps):
PtpIpClient(
GetLiveViewImageCommand(output, fps).run,
host = host,
port = port,
debug = debug
)
if __name__ == '__main__':
cli()