1# Copyright 2015 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import sys
16import its.device
17import its.objects
18import its.image
19
20def main():
21    """get camera ids and save it to disk.
22    """
23    out_path = ""
24    for s in sys.argv[1:]:
25        if s[:4] == "out=" and len(s) > 4:
26            out_path = s[4:]
27    # kind of weird we need to open a camera to get camera ids, but
28    # this is how ITS is working now.
29    with its.device.ItsSession() as cam:
30        camera_ids = cam.get_camera_ids()
31        if out_path != "":
32            with open(out_path, "w") as f:
33                for camera_id in camera_ids:
34                    f.write(camera_id + "\n")
35
36if __name__ == '__main__':
37    main()
38