-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path05-save.py
More file actions
executable file
·60 lines (41 loc) · 1.45 KB
/
05-save.py
File metadata and controls
executable file
·60 lines (41 loc) · 1.45 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python3
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2.1
# of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
import sys
import pyquid
import time
sw = pyquid.Switcher('save_example', debug=True)
# instantiate and use some quiddities
dum = sw.create(kind='dummysink', nickname='dum')
vid = sw.create('videotestsrc', 'vid')
connection = dum.try_connect(vid)
assert connection.disconnect()
connection = dum.try_connect(vid)
assert vid.set('started', True)
time.sleep(1)
# save the switcher state
sw.session.save_as("test_state")
# make another switcher
sw2 = pyquid.Switcher('pyQuidSave2')
# creating a quiddity that will not be affected by reloading
prop = sw2.create('property-quid')
# consider current state as initial state
sw2.reset_state(False)
# load the save file
sw.session.load("test_state")
# check dum and vid exist
assert 0 != sw.get_quid_id('dum')
assert 0 != sw.get_quid_id('vid')
time.sleep(1)
val = prop.get("string_")
print(str(val))
# prop is still here
assert val.isalnum()
# remove test session file
sw.session.remove("test_state")