hugs / castro Goto Github PK
View Code? Open in Web Editor NEW"screencast robot" - a tiny fork of pyvnc2swf
"screencast robot" - a tiny fork of pyvnc2swf
# Castro - screen/cast ro/bot # A tiny fork of pyvnc2swf, with a smidge of awesome on the side Install: 1) Install and launch a vncserver. (Hint: Google it.) 2) $ [sudo] easy_install castro 3) There's no step 3! Test: $ python -c "import castro; castro.test()" Watch: Video stored in: <default_temp_dir>/castro-video.swf Video player stored in: <default_temp_dir>/castro-video.html Linux/OSX: $ firefox /tmp/castro-video.html Windows: C:/> firefox.exe ???/castro-video.html Use: The Happy Path: >>> from castro import Castro >>> c = Castro() >>> c.start() >>> # Do something awesome! >>> c.stop() Host and display: (default is localhost:0) >>> c = Castro(host='example.com', display=1) Storage directory: $ export CASTRO_DATA_DIR=/home/me/screencasts $ python >>> from castro import Castro >>> c = Castro() Filename: (default is "castro-video.swf") >>> c = Castro(filename = "my-cool-screencast.swf") VNC password file: (default is "~/.vnc/passwd") >>> c = Castro(passwd = "/home/me/.vnc/passwd") Specify everything: $ export CASTRO_DATA_DIR=/home/me/screencasts $ python >>> from castro import Castro >>> c = Castro(host = 'example.com', display = 1, filename = "my-cool-screencast.swf", passwd = "/home/me/.vnc/passwd")
Just instaled castro in my project, where I use python 3.6 and got following error
Traceback (most recent call last):
File "/usr/local/lib/python3.6/unittest/loader.py", line 428, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/local/lib/python3.6/unittest/loader.py", line 369, in _get_module_from_name
import(name)
File "/app/src/test_auth.py", line 1, in
from .base import SeleniumTestCase
File "/app/src/base.py", line 9, in
from castro import Castro
File "/usr/local/lib/python3.6/site-packages/castro/init.py", line 110
print "Running ffmpeg: encoding and creating keyframes"
^
SyntaxError: Missing parentheses in call to 'print'
This is obviously python2 syntax, it would be nice to have a package that uses python 3
I feel like I'm getting close, but the generated SWF is only 70 bytes. Any ideas about the Socket errors / Broken pipe?
# get pygame something like http://juliaelman.com/blog/2013/04/02/installing-pygame-on-osx-mountain-lion/
brew install sdl sdl_ttf sdl_image sdl_mixer hg
pip install hg+http://bitbucket.org/pygame/pygame
# get castro
pip install castro
# Turn on VNC
* System Preferences > Sharing
* Enable Screen Sharing
* Allow access for all users
* Computer Settings > Enabled "VNC viewers may control screen with password" and set a password
# write an encrypted ~/.vnc/passwd file with your vnc password
mkdir ~/.vnc
cd /tmp
git clone https://github.com/trinitronx/vncpasswd.py.git
cd vncpasswd.py/
./vncpasswd.py -f ~/.vnc/passwd your-vnc-password
# encrypted password there seems legit
cat ~/.vnc/passwd | base64
29g8/XJ6FFg=
# try it out
cd /tmp
python -c "import castro; castro.test()"
Recording a 10 second video...
10 Connected: localhost:5900, protocol_version=3.3, preferred_encoding=(0, -232, -239)
9 VNC Screen: size=5440x2340, name='Jason\xe2\x80\x99s MacBook Pro'
Output movie size: 5440x2340
Creating movie: '/var/folders/qz/4yw7g_b560j9ns1hqk86tyrr0000gn/T/castro-video.swf': version=5, size=5440x2340, framerate=12, compression=None
Socket error: [Errno 32] Broken pipe
8 Connected: localhost:5900, protocol_version=3.3, preferred_encoding=(0, -232, -239)
VNC Screen: size=5440x2340, name='Jason\xe2\x80\x99s MacBook Pro'
RFB error: Connection closed unexpectedly.
7 Connected: localhost:5900, protocol_version=3.3, preferred_encoding=(0, -232, -239)
6 VNC Screen: size=5440x2340, name='Jason\xe2\x80\x99s MacBook Pro'
RFB error: Connection closed unexpectedly.
5 Connected: localhost:5900, protocol_version=3.3, preferred_encoding=(0, -232, -239)
VNC Screen: size=5440x2340, name='Jason\xe2\x80\x99s MacBook Pro'
RFB error: Connection closed unexpectedly.
Writing: /var/folders/qz/4yw7g_b560j9ns1hqk86tyrr0000gn/T/castro-video.html...
ls -lah /var/folders/qz/4yw7g_b560j9ns1hqk86tyrr0000gn/T/castro-video.swf
-rw-r--r-- 1 jason staff 70B Nov 19 15:29 /var/folders/qz/4yw7g_b560j9ns1hqk86tyrr0000gn/T/castro-video.swf
python -c "import castro; castro.test()"
Recording a 10 second video...
10 Connected: localhost:5900, protocol_version=3.8, preferred_encoding=(0, -232, -239)
VNC Screen: size=4960x1921, name='beast'
Output movie size: 4960x1921
Creating movie: 'c:\users\matt\appdata\local\temp\castro-video.swf': version=5, size=4960x1921, framerate=12, compression=None
9 8 7 6 5 4 3 2 1 Process Process-2:
Traceback (most recent call last):
File "c:\python27\lib\multiprocessing\process.py", line 232, in _bootstrap
self.run()
File "c:\python27\lib\multiprocessing\process.py", line 88, in run
self._target(_self._args, *_self._kwargs)
File "c:\python27\lib\site-packages\castro\lib\pyvnc2swf\vnc2swf.py", line 611, in main
merge=merge, debug=debug, reconnect=reconnect)
File "c:\python27\lib\site-packages\castro\lib\pyvnc2swf\vnc2swf.py", line 429, in vnc2swf
client.loop()
File "c:\python27\lib\site-packages\castro\lib\pyvnc2swf\rfb.py", line 489, in loop
if not self.loop1(): break
File "c:\python27\lib\site-packages\castro\lib\pyvnc2swf\rfb.py", line 448, in loop1
self.finish_update()
File "c:\python27\lib\site-packages\castro\lib\pyvnc2swf\rfb.py", line 136, in finish_update
self.fb.update_screen(time.time())
File "c:\python27\lib\site-packages\castro\lib\pyvnc2swf\rfb.py", line 839, in update_screen
self.stream.next_frame()
File "c:\python27\lib\site-packages\castro\lib\pyvnc2swf\output.py", line 564, in next_frame
self.add_object(self.screen.get_image(x0, y0, w, h), depth, x0, y0)
File "c:\python27\lib\site-packages\castro\lib\pyvnc2swf\output.py", line 531, in add_object
self.place_object2(self.define_shape(w, h, data), x, y, depth)
File "c:\python27\lib\site-packages\castro\lib\pyvnc2swf\output.py", line 431, in define_shape
self.writer.write_shape(3, [(0,(20,20)),(1,(w_20,0)),(1,(0,h_20)),(1,(-w_20,0)),(1,(0,-h_20))], fillstyle=1)
File "c:\python27\lib\site-packages\castro\lib\pyvnc2swf\swf.py", line 708, in write_shape
self.writebits(4, n-2)
File "c:\python27\lib\site-packages\castro\lib\pyvnc2swf\swf.py", line 545, in writebits
assert 0 <= x and x < (1<<bits)
AssertionError
The swf file is created, (37k), but is unplayable.
It also creates a large number (1 per second, approximately) of python.exe processes until the original processes is terminated.
Hi hugs, I'm trying to start a video using your lib but I'm facing this error who is very annoying
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(_self._args, *_self._kwargs)
File "/usr/local/lib/python2.7/site-packages/castro-1.0.6-py2.7.egg/castro/lib/pyvnc2swf/vnc2swf.py", line 611, in main
merge=merge, debug=debug, reconnect=reconnect)
File "/usr/local/lib/python2.7/site-packages/castro-1.0.6-py2.7.egg/castro/lib/pyvnc2swf/vnc2swf.py", line 429, in vnc2swf
client.loop()
File "/usr/local/lib/python2.7/site-packages/castro-1.0.6-py2.7.egg/castro/lib/pyvnc2swf/rfb.py", line 489, in loop
if not self.loop1(): break
File "/usr/local/lib/python2.7/site-packages/castro-1.0.6-py2.7.egg/castro/lib/pyvnc2swf/rfb.py", line 276, in loop1
self.request_update()
File "/usr/local/lib/python2.7/site-packages/castro-1.0.6-py2.7.egg/castro/lib/pyvnc2swf/rfb.py", line 551, in request_update
self.send('\x03\x01' + pack('>HHHH', *self.clipping))
AttributeError: RFBNetworkClient instance has no attribute 'clipping'
Here is my code for the video
from selenium import webdriver, selenium
from selenium.webdriver.common.keys import Keys
import castro
class Video(object):
def init(self, _args, *_kwargs):
self.verificationErrors = []
self.video = castro.Castro()
self.driver = webdriver.Firefox()
super(Video, self).init()
def manager_video(self):
self.video.start()
self.driver.get('http://www.n1ght.com')
element = self.driver.find_element_by_id("appendedInputButton")
element.send_keys("brussel")
self.driver.close()
self.video.stop()
self.video.process()
I normally installed all dependancies so don't understand why it's not working when I do video.start()
Thank you in advance
Here's my code---
import castro
video = castro.Castro()
video.start()
The error is -
Socket error: [Errno 111] Connection refused
Process Process-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(_self._args, *_self._kwargs)
File "/usr/local/lib/python2.7/dist-packages/castro-1.0.6-py2.6.egg/castro/lib/pyvnc2swf/vnc2swf.py", line 611, in main
merge=merge, debug=debug, reconnect=reconnect)
File "/usr/local/lib/python2.7/dist-packages/castro-1.0.6-py2.6.egg/castro/lib/pyvnc2swf/vnc2swf.py", line 429, in vnc2swf
client.loop()
File "/usr/local/lib/python2.7/dist-packages/castro-1.0.6-py2.6.egg/castro/lib/pyvnc2swf/rfb.py", line 489, in loop
if not self.loop1(): break
File "/usr/local/lib/python2.7/dist-packages/castro-1.0.6-py2.6.egg/castro/lib/pyvnc2swf/rfb.py", line 276, in loop1
self.request_update()
File "/usr/local/lib/python2.7/dist-packages/castro-1.0.6-py2.6.egg/castro/lib/pyvnc2swf/rfb.py", line 551, in request_update
self.send('\x03\x01' + pack('>HHHH', *self.clipping))
AttributeError: RFBNetworkClient instance has no attribute 'clipping'
Any idea why "pip install castro" on Ubuntu tries to download pygame for Osx?
When I try to run Castro, I get this error:
ModuleNotFoundError: No module named 'lib.messageboard'
Where can I get this library? I can't find it.
Just try running 'python -c "import castro"' on windows 7
I think it would be very interesting to create a docker image to be used for the Castro library. I need to use it to record videos in Selenium tests and I can't find any other solution.
Bad news, It does not support Python3 yet.
I get the following traceback message when trying to run a module that imports castro:
tests/examples/test_website.py:4: in
from castro import Castro
E File "/Users/derek/dev/v3/lib/python3.11/site-packages/castro/init.py", line 110
E print "Running ffmpeg: encoding and creating keyframes"
E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
I see 4 print statements missing the parens. I'm running python 3.11.2 on OSX 12.6.3.
If I do this:
>>> c = Castro(filename = "my-cool-screencast.swf")
... everything is great.
BUT, if I do this:
>>> c = Castro(filename = "my-cool-screencast.vnc")
... I get this traceback:
>>> Process Process-1:
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/processing-0.52-py2.5-linux-i686.eg
self.run()
File "/usr/lib/python2.5/site-packages/processing-0.52-py2.5-linux-i686.eg
self._target(_self._args, *_self._kwargs)
File "/usr/lib/python2.5/site-packages/castro-1.0-py2.5.egg/castro/lib/pyv
merge=merge, debug=debug)
File "/usr/lib/python2.5/site-packages/castro-1.0-py2.5.egg/castro/lib/pyv
stream.close()
UnboundLocalError: local variable 'stream' referenced before assignment
Finding files... done.
Importing test modules ... done.
Traceback (most recent call last):
File "/home/anuj/workspace/parallel_wd/examples/recording_test.py", line 27, in tearDown
self.video.process()
File "/usr/local/lib/python2.7/dist-packages/castro-1.0.6-py2.7.egg/castro/init.py", line 99, in process
self.calc_duration()
File "/usr/local/lib/python2.7/dist-packages/castro-1.0.6-py2.7.egg/castro/init.py", line 125, in calc_duration
self.duration = int(round(flv_data[flv_data.keys()[0]]['duration']))
TypeError: string indices must be integers, not str
Ran 1 test in 10.715s
FAILED (errors=1)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.