pyca 4.4__tar.gz → 4.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. pyca-4.6/LICENSE +165 -0
  2. pyca-4.6/PKG-INFO +71 -0
  3. pyca-4.6/README.md +51 -0
  4. {pyca-4.4 → pyca-4.6}/pyca/__init__.py +1 -1
  5. {pyca-4.4 → pyca-4.6}/pyca/__main__.py +18 -3
  6. {pyca-4.4 → pyca-4.6}/pyca/agentstate.py +1 -1
  7. {pyca-4.4 → pyca-4.6}/pyca/capture.py +2 -2
  8. {pyca-4.4 → pyca-4.6}/pyca/config.py +11 -3
  9. {pyca-4.4 → pyca-4.6}/pyca/db.py +1 -1
  10. {pyca-4.4 → pyca-4.6}/pyca/ingest.py +11 -7
  11. {pyca-4.4 → pyca-4.6}/pyca/schedule.py +2 -2
  12. {pyca-4.4 → pyca-4.6}/pyca/ui/__init__.py +1 -1
  13. pyca-4.6/pyca/ui/capture_devices_collector.py +32 -0
  14. {pyca-4.4 → pyca-4.6}/pyca/ui/jsonapi.py +44 -3
  15. pyca-4.6/pyca/ui/opencast_commands.py +80 -0
  16. pyca-4.6/pyca/ui/static/app.js +324 -0
  17. pyca-4.6/pyca/ui/static/index.html +107 -0
  18. pyca-4.6/pyca/ui/static/style.css +208 -0
  19. {pyca-4.4 → pyca-4.6}/pyca/ui/utils.py +6 -5
  20. {pyca-4.4 → pyca-4.6}/pyca/utils.py +20 -4
  21. pyca-4.6/pyca.egg-info/PKG-INFO +71 -0
  22. {pyca-4.4 → pyca-4.6}/pyca.egg-info/SOURCES.txt +9 -10
  23. {pyca-4.4 → pyca-4.6}/pyca.egg-info/entry_points.txt +0 -1
  24. {pyca-4.4 → pyca-4.6}/pyca.egg-info/requires.txt +1 -1
  25. pyca-4.6/pyca.egg-info/top_level.txt +1 -0
  26. pyca-4.6/pyproject.toml +37 -0
  27. {pyca-4.4 → pyca-4.6}/tests/test_agentstate.py +1 -1
  28. {pyca-4.4 → pyca-4.6}/tests/test_capture.py +1 -1
  29. {pyca-4.4 → pyca-4.6}/tests/test_db.py +2 -1
  30. {pyca-4.4 → pyca-4.6}/tests/test_ingest.py +1 -1
  31. {pyca-4.4 → pyca-4.6}/tests/test_main.py +34 -0
  32. {pyca-4.4 → pyca-4.6}/tests/test_restapi.py +51 -5
  33. {pyca-4.4 → pyca-4.6}/tests/test_schedule.py +1 -1
  34. pyca-4.6/tests/test_ui_opencast_commands.py +19 -0
  35. {pyca-4.4 → pyca-4.6}/tests/test_utils.py +4 -4
  36. pyca-4.4/PKG-INFO +0 -75
  37. pyca-4.4/README.rst +0 -64
  38. pyca-4.4/pyca/ui/static/func.505dd7ab.css +0 -1
  39. pyca-4.4/pyca/ui/static/func.d1932981.js +0 -90
  40. pyca-4.4/pyca/ui/static/func.d1932981.js.map +0 -1
  41. pyca-4.4/pyca/ui/static/index.html +0 -5
  42. pyca-4.4/pyca/ui/static/style.7e280de9.css +0 -2
  43. pyca-4.4/pyca/ui/static/style.7e280de9.css.map +0 -1
  44. pyca-4.4/pyca.egg-info/PKG-INFO +0 -75
  45. pyca-4.4/pyca.egg-info/top_level.txt +0 -2
  46. pyca-4.4/setup.py +0 -40
  47. pyca-4.4/tests/__init__.py +0 -0
  48. pyca-4.4/tests/tools.py +0 -64
  49. {pyca-4.4 → pyca-4.6}/MANIFEST.in +0 -0
  50. {pyca-4.4 → pyca-4.6}/pyca/ui/process_status_collector.py +0 -0
  51. {pyca-4.4 → pyca-4.6}/pyca/ui/recordings_collector.py +0 -0
  52. {pyca-4.4 → pyca-4.6}/pyca.egg-info/dependency_links.txt +0 -0
  53. {pyca-4.4 → pyca-4.6}/setup.cfg +0 -0
  54. {pyca-4.4 → pyca-4.6}/tests/test_config.py +0 -0
  55. {pyca-4.4 → pyca-4.6}/tests/test_ui.py +0 -0
pyca-4.6/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
pyca-4.6/PKG-INFO ADDED
@@ -0,0 +1,71 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyca
3
+ Version: 4.6
4
+ Summary: Opencast Capture Agent
5
+ Author-email: Lars Kiesow <lkiesow@uos.de>
6
+ License-Expression: LGPL-3.0-only
7
+ Project-URL: Homepage, https://github.com/opencast/pyCA
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: pycurl>=7.19.5
12
+ Requires-Dist: python-dateutil>=2.4.0
13
+ Requires-Dist: configobj>=5.0.0
14
+ Requires-Dist: sqlalchemy>=0.9.8
15
+ Requires-Dist: sdnotify>=0.3.2
16
+ Requires-Dist: psutil>=5.0.1
17
+ Requires-Dist: flask>=0.12.2
18
+ Requires-Dist: prometheus_client>=0.9
19
+ Dynamic: license-file
20
+
21
+ # PyCA – Opencast Capture Agent
22
+
23
+ [![Test pyCA GitHub Workflow Status](https://github.com/opencast/pyCA/actions/workflows/test.yml/badge.svg)](https://github.com/opencast/pyCA/actions/workflows/test.yml)
24
+ [![LGPL-3 license](https://img.shields.io/github/license/opencast/pyCA)](https://github.com/opencast/pyCA/blob/main/LICENSE)
25
+
26
+ **PyCA** is a fully functional [Opencast] capture agent written in Python.
27
+ It is free software licensed under the terms of the [GNU Lesser General Public
28
+ License].
29
+
30
+ The goals of pyCA are to be…
31
+
32
+ - flexible for any kind of capture device
33
+ - simplistic in code and functionality
34
+ - nonrestrictive in terms of choosing capture software
35
+
36
+ PyCA can be run on almost any kind of devices: A regular PC equipped with
37
+ capture cards, a server to capture network streams, small boards or embedded
38
+ devices like the [Raspberry Pi].
39
+
40
+
41
+ ## Python Versions
42
+
43
+ PyCA requires Python ≥ 3.10. Older versions of Python will not work.
44
+
45
+
46
+ ## Documentation
47
+
48
+ For a detailed installation guide, take a look at the [PyCA documentation].
49
+
50
+
51
+ ## Quick Install for Experienced Users
52
+
53
+ PyCA is configured to use [FFmpeg] by default.
54
+ Make sure to have it installed or adjust the configuration to use something else.
55
+
56
+ ```bash
57
+ git clone https://github.com/opencast/pyCA.git
58
+ cd pyCA
59
+ python3 -m venv venv
60
+ . ./venv/bin/activate
61
+ pip install -r requirements.txt
62
+ vim etc/pyca.conf <-- Edit the configuration
63
+ ./start.sh
64
+ ```
65
+
66
+
67
+ [Opencast]: https://opencast.org
68
+ [GNU Lesser General Public License]: https://github.com/opencast/pyCA/blob/main/LICENSE
69
+ [Raspberry Pi]: https://raspberrypi.org
70
+ [FFmpeg]: https://ffmpeg.org
71
+ [PyCA documentation]: https://github.com/opencast/pyCA/tree/main/docs#welcome-to-the-pyca-documentation
pyca-4.6/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # PyCA – Opencast Capture Agent
2
+
3
+ [![Test pyCA GitHub Workflow Status](https://github.com/opencast/pyCA/actions/workflows/test.yml/badge.svg)](https://github.com/opencast/pyCA/actions/workflows/test.yml)
4
+ [![LGPL-3 license](https://img.shields.io/github/license/opencast/pyCA)](https://github.com/opencast/pyCA/blob/main/LICENSE)
5
+
6
+ **PyCA** is a fully functional [Opencast] capture agent written in Python.
7
+ It is free software licensed under the terms of the [GNU Lesser General Public
8
+ License].
9
+
10
+ The goals of pyCA are to be…
11
+
12
+ - flexible for any kind of capture device
13
+ - simplistic in code and functionality
14
+ - nonrestrictive in terms of choosing capture software
15
+
16
+ PyCA can be run on almost any kind of devices: A regular PC equipped with
17
+ capture cards, a server to capture network streams, small boards or embedded
18
+ devices like the [Raspberry Pi].
19
+
20
+
21
+ ## Python Versions
22
+
23
+ PyCA requires Python ≥ 3.10. Older versions of Python will not work.
24
+
25
+
26
+ ## Documentation
27
+
28
+ For a detailed installation guide, take a look at the [PyCA documentation].
29
+
30
+
31
+ ## Quick Install for Experienced Users
32
+
33
+ PyCA is configured to use [FFmpeg] by default.
34
+ Make sure to have it installed or adjust the configuration to use something else.
35
+
36
+ ```bash
37
+ git clone https://github.com/opencast/pyCA.git
38
+ cd pyCA
39
+ python3 -m venv venv
40
+ . ./venv/bin/activate
41
+ pip install -r requirements.txt
42
+ vim etc/pyca.conf <-- Edit the configuration
43
+ ./start.sh
44
+ ```
45
+
46
+
47
+ [Opencast]: https://opencast.org
48
+ [GNU Lesser General Public License]: https://github.com/opencast/pyCA/blob/main/LICENSE
49
+ [Raspberry Pi]: https://raspberrypi.org
50
+ [FFmpeg]: https://ffmpeg.org
51
+ [PyCA documentation]: https://github.com/opencast/pyCA/tree/main/docs#welcome-to-the-pyca-documentation
@@ -4,5 +4,5 @@
4
4
  ~~~~~~~~~~~~~~~~~~~~
5
5
 
6
6
  :copyright: 2014-2015, Lars Kiesow <lkiesow@uos.de>
7
- :license: LGPL – see license.lgpl for more details.
7
+ :license: LGPL – see LICENSE for more details.
8
8
  '''
@@ -4,7 +4,7 @@
4
4
  ~~~~~~~~~~~~~~~~~~~~
5
5
 
6
6
  :copyright: 2014-2017, Lars Kiesow <lkiesow@uos.de>
7
- :license: LGPL – see license.lgpl for more details.
7
+ :license: LGPL – see LICENSE for more details.
8
8
  '''
9
9
 
10
10
  import getopt
@@ -14,11 +14,18 @@ import sys
14
14
  from pyca import capture, config, schedule, ingest, ui, agentstate, utils
15
15
  from pyca.db import get_session
16
16
 
17
+ # The services run in their own processes and rely on inheriting the state of
18
+ # the main process, like the configuration loaded from the file specified on
19
+ # the command line and the signal handlers. Only the fork start method does
20
+ # that, but it is no longer the default since Python 3.14.
21
+ fork_context = multiprocessing.get_context('fork')
22
+
17
23
  USAGE = '''
18
24
  Usage %s [OPTIONS] COMMAND
19
25
 
20
26
  COMMANDS:
21
27
  run -- Start all pyCA components except ui (default)
28
+ all -- Start all components (for testing only)
22
29
  capture -- Start pyCA capture service
23
30
  ingest -- Start pyCA ingest service
24
31
  schedule -- Start pyCA schedule service
@@ -54,7 +61,7 @@ def sigterm_handler(signum, frame):
54
61
  '''Intercept sigterm and terminate all processes.
55
62
  '''
56
63
  sigint_handler(signum, frame)
57
- for process in multiprocessing.active_children():
64
+ for process in fork_context.active_children():
58
65
  process.terminate()
59
66
  sys.exit(0)
60
67
 
@@ -62,7 +69,7 @@ def sigterm_handler(signum, frame):
62
69
  def run_all(*modules):
63
70
  '''Start all services.
64
71
  '''
65
- processes = [multiprocessing.Process(target=mod.run) for mod in modules]
72
+ processes = [fork_context.Process(target=mod.run) for mod in modules]
66
73
  for p in processes:
67
74
  p.start()
68
75
  for p in processes:
@@ -105,6 +112,14 @@ def main():
105
112
  # ensure database is created first
106
113
  get_session().close()
107
114
  run_all(schedule, capture, ingest, agentstate)
115
+ elif cmd == 'all':
116
+ get_session().close()
117
+ signal.signal(signal.SIGINT, signal.default_int_handler)
118
+ fork_context.Process(
119
+ target=ui.app.run,
120
+ kwargs={'threaded': False}
121
+ ).start()
122
+ run_all(schedule, capture, ingest, agentstate)
108
123
  elif cmd == 'schedule':
109
124
  schedule.run()
110
125
  elif cmd == 'capture':
@@ -4,7 +4,7 @@
4
4
  ~~~~~~~~~~~~~~~~~~~~
5
5
 
6
6
  :copyright: 2014-2017, Lars Kiesow <lkiesow@uos.de>
7
- :license: LGPL – see license.lgpl for more details.
7
+ :license: LGPL – see LICENSE for more details.
8
8
  '''
9
9
 
10
10
  from pyca.utils import set_service_status, update_agent_state, timestamp
@@ -4,14 +4,14 @@
4
4
  ~~~~~~~~~~~~~~~~~~~~
5
5
 
6
6
  :copyright: 2014-2017, Lars Kiesow <lkiesow@uos.de>
7
- :license: LGPL – see license.lgpl for more details.
7
+ :license: LGPL – see LICENSE for more details.
8
8
  '''
9
9
 
10
10
  from pyca.utils import timestamp, try_mkdir, terminate
11
11
  from pyca.utils import set_service_status, set_service_status_immediate
12
12
  from pyca.utils import recording_state, update_event_status
13
13
  from pyca.config import config
14
- from pyca.db import get_session, RecordedEvent, UpcomingEvent, Status,\
14
+ from pyca.db import get_session, RecordedEvent, UpcomingEvent, Status, \
15
15
  Service, ServiceStatus, with_session
16
16
  import glob
17
17
  import logging
@@ -43,11 +43,13 @@ upload_rate = string(default='0')
43
43
 
44
44
  [server]
45
45
  url = string(default='https://develop.opencast.org')
46
- auth_method = option('basic', 'digest', default='digest')
47
- username = string(default='opencast_system_account')
48
- password = string(default='CHANGE_ME')
46
+ auth_method = option('basic', 'digest', default='basic')
47
+ username = string(default='admin')
48
+ password = string(default='opencast')
49
49
  insecure = boolean(default=False)
50
50
  certificate = string(default='')
51
+ cookiefile = string(default='')
52
+ [[service_overrides]]
51
53
 
52
54
  [ui]
53
55
  username = string(default='admin')
@@ -63,6 +65,10 @@ file = string(default='')
63
65
  level = option('debug', 'info', 'warning', 'error', default='info')
64
66
  format = string(default='[%(name)s:%(lineno)s:%(funcName)s()] [%(levelname)s] %(message)s')
65
67
 
68
+ [http]
69
+ timeout = integer(min=0, default=300)
70
+ connection_timeout = integer(min=0, default=180)
71
+
66
72
  [services]
67
73
  ''' # noqa
68
74
 
@@ -164,6 +170,8 @@ def logger_init():
164
170
  handlers.append(logging.StreamHandler(sys.stderr))
165
171
  if logconf['file']:
166
172
  handlers.append(logging.handlers.WatchedFileHandler(logconf['file']))
173
+ if logging.root.hasHandlers():
174
+ logging.root.handlers.clear()
167
175
  for handler in handlers:
168
176
  handler.setFormatter(logging.Formatter(logconf['format']))
169
177
  logging.root.addHandler(handler)
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  '''
3
3
  pyca.db
4
- ~~~~¨~~
4
+ ~~~~~~~
5
5
 
6
6
  Database specification for pyCA
7
7
  '''
@@ -4,7 +4,7 @@
4
4
  ~~~~~~~~~~~~~~~~~~~~
5
5
 
6
6
  :copyright: 2014-2017, Lars Kiesow <lkiesow@uos.de>
7
- :license: LGPL – see license.lgpl for more details.
7
+ :license: LGPL – see LICENSE for more details.
8
8
  '''
9
9
 
10
10
  from pyca.config import config
@@ -53,12 +53,13 @@ def ingest(event):
53
53
  # ingest services to ensure that not every capture agent uses the same
54
54
  # service at the same time
55
55
  service_url = service('ingest', force_update=True)
56
- service_url = service_url[random.randrange(0, len(service_url))]
56
+ # nosec: we do not need a secure random number here
57
+ service_url = service_url[random.randrange(0, len(service_url))] # nosec
57
58
  logger.info('Selecting ingest service to use: ' + service_url)
58
59
 
59
60
  # create mediapackage
60
61
  logger.info('Creating new mediapackage')
61
- mediapackage = http_request(service_url + '/createMediaPackage')
62
+ mediapackage = http_request(service_url + '/createMediaPackage', timeout=0)
62
63
 
63
64
  # extract workflow_def, workflow_config and add DC catalogs
64
65
  prop = 'org.opencastproject.capture.agent.properties'
@@ -77,7 +78,8 @@ def ingest(event):
77
78
  fields = [('mediaPackage', mediapackage),
78
79
  ('flavor', 'dublincore/%s' % name),
79
80
  ('dublinCore', data.encode('utf-8'))]
80
- mediapackage = http_request(service_url + '/addDCCatalog', fields)
81
+ mediapackage = http_request(service_url + '/addDCCatalog', fields,
82
+ timeout=0)
81
83
 
82
84
  else:
83
85
  logger.info('Not uploading %s', attachment.get('x-apple-filename'))
@@ -89,7 +91,8 @@ def ingest(event):
89
91
  track = track.encode('ascii', 'ignore')
90
92
  fields = [('mediaPackage', mediapackage), ('flavor', flavor),
91
93
  ('BODY1', (pycurl.FORM_FILE, track))]
92
- mediapackage = http_request(service_url + '/addTrack', fields)
94
+ mediapackage = http_request(service_url + '/addTrack', fields,
95
+ timeout=0)
93
96
 
94
97
  # ingest
95
98
  logger.info('Ingest recording')
@@ -100,7 +103,7 @@ def ingest(event):
100
103
  fields.append(('workflowInstanceId',
101
104
  event.uid.encode('ascii', 'ignore')))
102
105
  fields += workflow_config
103
- mediapackage = http_request(service_url + '/ingest', fields)
106
+ mediapackage = http_request(service_url + '/ingest', fields, timeout=0)
104
107
 
105
108
  # Update status
106
109
  recording_state(event.uid, 'upload_finished')
@@ -144,7 +147,8 @@ def control_loop():
144
147
  .filter(RecordedEvent.status ==
145
148
  Status.FINISHED_RECORDING).first()
146
149
  if event:
147
- delay = random.randint(config('ingest', 'delay_min'),
150
+ # nosec: we do not need a secure random number here
151
+ delay = random.randint(config('ingest', 'delay_min'), # nosec
148
152
  config('ingest', 'delay_max'))
149
153
  logger.info("Delaying ingest for %s seconds", delay)
150
154
  time.sleep(delay)
@@ -4,7 +4,7 @@
4
4
  ~~~~~~~~~~~~~~~~~~~~
5
5
 
6
6
  :copyright: 2014-2017, Lars Kiesow <lkiesow@uos.de>
7
- :license: LGPL – see license.lgpl for more details.
7
+ :license: LGPL – see LICENSE for more details.
8
8
  '''
9
9
 
10
10
  from pyca.utils import http_request, service, timestamp, terminate, \
@@ -30,7 +30,7 @@ def parse_ical(vcal):
30
30
  '''
31
31
  vcal = vcal.replace('\r\n ', '').replace('\r\n\r\n', '\r\n')
32
32
  vevents = vcal.split('\r\nBEGIN:VEVENT\r\n')
33
- del(vevents[0])
33
+ del vevents[0]
34
34
  events = []
35
35
  for vevent in vevents:
36
36
  event = {}
@@ -4,7 +4,7 @@ Simple UI telling about the current state of the capture agent.
4
4
  '''
5
5
  from flask import Flask, send_from_directory, redirect, url_for, make_response
6
6
  from prometheus_client import generate_latest, CONTENT_TYPE_LATEST
7
- from pyca.ui import process_status_collector, recordings_collector # noqa
7
+ from pyca.ui import capture_devices_collector, process_status_collector, recordings_collector # noqa
8
8
  from pyca.config import config
9
9
  from pyca.ui.utils import requires_auth
10
10
  import os.path
@@ -0,0 +1,32 @@
1
+ from prometheus_client.metrics_core import GaugeMetricFamily
2
+ from prometheus_client.registry import REGISTRY
3
+
4
+ import glob
5
+
6
+
7
+ class CaptureDevicesCollector(object):
8
+ '''Return metrics about available capture devices.
9
+ '''
10
+
11
+ def __init__(self, registry=REGISTRY):
12
+ registry.register(self)
13
+
14
+ def collect(self):
15
+ devices = GaugeMetricFamily(
16
+ 'video_devices',
17
+ 'Available video devices',
18
+ labels=['device']
19
+ )
20
+
21
+ device_list = glob.glob('/dev/video*')
22
+
23
+ for device in device_list:
24
+ devices.add_metric(
25
+ [device],
26
+ value=1.0
27
+ )
28
+
29
+ yield devices
30
+
31
+
32
+ CAPTURE_DEVICES_COLLECTOR = CaptureDevicesCollector()
@@ -6,6 +6,7 @@ from pyca.db import Service, ServiceStatus, UpcomingEvent, \
6
6
  from pyca.db import with_session, Status, ServiceStates
7
7
  from pyca.ui import app
8
8
  from pyca.ui.utils import requires_auth, jsonapi_mediatype
9
+ from pyca.ui.opencast_commands import schedule
9
10
  from pyca.utils import get_service_status, ensurelist, timestamp
10
11
  import logging
11
12
  import os
@@ -151,7 +152,10 @@ def modify_event(db, uid):
151
152
  of the scheduler cache cannot be modified.
152
153
  '''
153
154
  try:
154
- data = request.get_json()['data'][0]
155
+ data = request.get_json()['data']
156
+ if len(data) != 1:
157
+ return make_error_response('Invalid data', 400)
158
+ data = data[0]
155
159
  if data['type'] != 'event' or data['id'] != uid:
156
160
  return make_error_response('Invalid data', 400)
157
161
  # Check attributes
@@ -222,8 +226,8 @@ def metrics(dbs):
222
226
  'available': memory.available,
223
227
  'used': memory.used,
224
228
  'free': memory.free,
225
- 'cached': memory.cached,
226
- 'buffers': memory.buffers,
229
+ 'cached': getattr(memory, 'cached', None),
230
+ 'buffers': getattr(memory, 'buffers', None),
227
231
  },
228
232
  'load': {
229
233
  '1m': load_1m,
@@ -246,6 +250,8 @@ def logs():
246
250
  if not cmd:
247
251
  return make_error_response('Logs are disabled.', 404)
248
252
 
253
+ # We specifically allow shell. This is no security issue since only admins
254
+ # may specify this command.
249
255
  logs = subprocess.run(cmd, shell=True, check=True, stdout=subprocess.PIPE,
250
256
  stderr=subprocess.STDOUT)\
251
257
  .stdout\
@@ -257,3 +263,38 @@ def logs():
257
263
  'type': 'logs',
258
264
  'attributes': {
259
265
  'lines': logs}})
266
+
267
+
268
+ @app.route('/api/schedule', methods=['POST'])
269
+ @requires_auth
270
+ @jsonapi_mediatype
271
+ def schedule_event():
272
+ try:
273
+ # We only allow one schedule at a time
274
+ print(0, request)
275
+ print(1, request.data)
276
+ print(2, request.get_json())
277
+ data = request.get_json()['data']
278
+ if len(data) != 1:
279
+ return make_error_response('Invalid data', 400)
280
+ data = data[0]
281
+
282
+ # Check attributes
283
+ for key in data.keys():
284
+ if key not in ('title', 'duration', 'creator'):
285
+ return make_error_response('Invalid data', 400)
286
+
287
+ # Check duration
288
+ if type(data['duration']) is not int:
289
+ return make_error_response('Duration must be an integer', 400)
290
+ except Exception as e:
291
+ logger.debug('bad request', e)
292
+ return make_error_response('Invalid data', 400)
293
+
294
+ try:
295
+ schedule(title=data.get('title', 'pyCA Recording'),
296
+ duration=data['duration'],
297
+ creator=data.get('creator', config('ui', 'username')))
298
+ except Exception:
299
+ return make_error_response('Scheduling conflict', 409)
300
+ return make_data_response('Event scheduled')