diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 54441be..eb8983f --- a/README.md +++ b/README.md @@ -20,9 +20,9 @@ This tool can run on Linux, Windows and MAC. ## Install and Run -1. pip install Flask-Bootstrap pyscreenshot +1. pip install flask-bootstrap pyscreenshot -2. In a directory, run "**git clone https://gitlab.com/qijungu/screenshare.git**". You will have a new directory "screenshare" with code inside. +2. In a directory, run "**git clone https://github.com/qijungu/screenshare.git**". You will have a new directory "screenshare" with code inside. 3. To start the screen sharing service, run "**python screenshare.py [port]**". diff --git a/__init__.py b/__init__.py old mode 100644 new mode 100755 diff --git a/screen.py b/screen.py old mode 100644 new mode 100755 index d630858..f8c336d --- a/screen.py +++ b/screen.py @@ -1,13 +1,24 @@ # -*- coding: utf-8 -*- -import threading, StringIO, time, base64 +import threading, time, base64 import pyscreenshot as ig +import sys + +ver = sys.version_info.major +if ver==2: + import StringIO +elif ver==3: + import io + class Screen(): def __init__(self): self.FPS = 10 self.screenbuf = "" - self.screenfile = StringIO.StringIO() + if ver==2: + self.screenfile = StringIO.StringIO() + elif ver==3: + self.screenfile = io.BytesIO() threading.Thread(target=self.getframes).start() def __del__(self): @@ -15,13 +26,19 @@ class Screen(): def getframes(self): while True: - im = ig.grab(childprocess=False) + im = ig.grab(childprocess=False,backend="pygdk3") + self.screenfile.seek(0) self.screenfile.truncate(0) im.save(self.screenfile, format="jpeg", quality=75, progressive=True) self.screenbuf = base64.b64encode(self.screenfile.getvalue()) time.sleep(1.0/self.FPS) def gen(self): - return self.screenbuf + s = '' + if ver==2: + s = self.screenbuf + elif ver==3: + s = self.screenbuf.decode() + return s -screenlive = Screen() \ No newline at end of file +screenlive = Screen() diff --git a/screenshare.py b/screenshare.py old mode 100644 new mode 100755 index 8d54823..964c71a --- a/screenshare.py +++ b/screenshare.py @@ -1,3 +1,4 @@ +#!/usr/bin/python # -*- coding: utf-8 -*- from flask import Flask diff --git a/static/css/common.css b/static/css/common.css old mode 100644 new mode 100755 diff --git a/static/css/jquery-confirm.min.css b/static/css/jquery-confirm.min.css old mode 100644 new mode 100755 diff --git a/static/js/jquery-confirm.min.js b/static/js/jquery-confirm.min.js old mode 100644 new mode 100755 diff --git a/static/js/screen.js b/static/js/screen.js old mode 100644 new mode 100755 diff --git a/templates/screen.html b/templates/screen.html old mode 100644 new mode 100755