Compare commits
11
Commits
970bb33b46
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa503941ee | ||
|
|
5002d5a8fe | ||
|
|
1da8287a9d | ||
|
|
679ce285b4 | ||
|
|
7a00d8b440 | ||
|
|
16ca19db37 | ||
|
|
f45f25dd9d | ||
|
|
3ccb9c9b60 | ||
|
|
03ca9b0a48 | ||
|
|
26de7e1d61 | ||
|
|
bd595d03b8 |
No files matched your search
@@ -124,6 +124,7 @@ celerybeat.pid
|
|||||||
# Environments
|
# Environments
|
||||||
.env
|
.env
|
||||||
.venv
|
.venv
|
||||||
|
.envrc
|
||||||
env/
|
env/
|
||||||
venv/
|
venv/
|
||||||
ENV/
|
ENV/
|
||||||
|
|||||||
+8
-3
@@ -19,10 +19,15 @@ the sample scripts are described in the examples/README
|
|||||||
a small set of samples are provided. all of them make use of the module
|
a small set of samples are provided. all of them make use of the module
|
||||||
pywmgeneral.
|
pywmgeneral.
|
||||||
|
|
||||||
|
[REQUIREMENTS DEBIAN/UBUNTU]
|
||||||
|
apt-get install mplayer python3-setuptools libx11-dev libxpm-dev libxext-dev
|
||||||
|
|
||||||
[INSTALLATION]
|
[INSTALLATION]
|
||||||
python ./setup install
|
sudo python ./setup install
|
||||||
|
|
||||||
[CONTACT]
|
[CONTACT]
|
||||||
Anything related to this piece of software can be e-mailed to me, Mario
|
This project was originally started as as a Python 2 application. By Mario
|
||||||
Frasca <mfrasca@interia.pl>.
|
Fransca <mfrasca@interia.pl>. I thank him for all the hard work.
|
||||||
|
|
||||||
|
The project has been ported to Python 3 and now maintained by Fredrick
|
||||||
|
Warren <fwarren@fastmail.com>
|
||||||
+30
-25
@@ -2,14 +2,20 @@
|
|||||||
|
|
||||||
"""pywmnop.py
|
"""pywmnop.py
|
||||||
|
|
||||||
WindowMaker dockapp doing nothing
|
WindowMaker dockapp internet radio player
|
||||||
|
|
||||||
Copyright (C) 2006 Mario Frasca
|
Copyright (C) 2006 Mario Frasca
|
||||||
|
|
||||||
Licensed under the GNU General Public License.
|
Licensed under the GNU General Public License.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys, time
|
from codecs import open
|
||||||
|
from fcntl import fcntl, F_GETFL, F_SETFL
|
||||||
|
from os import environ, sep, O_NONBLOCK
|
||||||
|
from re import compile
|
||||||
|
from select import select
|
||||||
|
from signal import signal, SIGCHLD
|
||||||
|
from subprocess import Popen, DEVNULL, PIPE
|
||||||
from wmdocklib import wmoo as wmoo
|
from wmdocklib import wmoo as wmoo
|
||||||
|
|
||||||
class Application(wmoo.Application):
|
class Application(wmoo.Application):
|
||||||
@@ -33,16 +39,12 @@ class Application(wmoo.Application):
|
|||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
self._buffered = ''
|
self._buffered = ''
|
||||||
import re
|
self._feedback = compile(r'.+A:.*?% ([0-9\.]+)%')
|
||||||
self._feedback = re.compile(r'.+A:.*?% ([0-9\.]+)%')
|
|
||||||
|
|
||||||
import fileinput, os
|
configfile = sep.join([environ['HOME'], '.pyradiorc'])
|
||||||
configfile = os.sep.join([os.environ['HOME'], '.pyradiorc'])
|
|
||||||
|
|
||||||
import codecs
|
with open(configfile, 'r', 'utf-8') as f:
|
||||||
f = codecs.open(configfile, 'r', 'utf-8')
|
|
||||||
t = f.read()
|
t = f.read()
|
||||||
f.close()
|
|
||||||
for i in t.split(u'\n'):
|
for i in t.split(u'\n'):
|
||||||
radiodef = i.split('\t')
|
radiodef = i.split('\t')
|
||||||
radioname = radiodef[0].lower()
|
radioname = radiodef[0].lower()
|
||||||
@@ -57,7 +59,6 @@ class Application(wmoo.Application):
|
|||||||
|
|
||||||
def handler(self, num, frame):
|
def handler(self, num, frame):
|
||||||
if self._expectdying:
|
if self._expectdying:
|
||||||
print(self._expectdying)
|
|
||||||
self._expectdying -= 1
|
self._expectdying -= 1
|
||||||
else:
|
else:
|
||||||
self.reset()
|
self.reset()
|
||||||
@@ -65,37 +66,41 @@ class Application(wmoo.Application):
|
|||||||
self._colour = 1
|
self._colour = 1
|
||||||
|
|
||||||
def startPlayer(self):
|
def startPlayer(self):
|
||||||
import os, subprocess, signal
|
|
||||||
commandline = [mplayer,
|
commandline = [mplayer,
|
||||||
'-cache', self.radioList[self.currentRadio][2],
|
'-cache',
|
||||||
|
str(abs(int(self.radioList[self.currentRadio][2]))),
|
||||||
self.radioList[self.currentRadio][1]
|
self.radioList[self.currentRadio][1]
|
||||||
]
|
]
|
||||||
self.child = subprocess.Popen(commandline,
|
# if cache is negative then this is a playlist
|
||||||
stdin =subprocess.PIPE,
|
if int(self.radioList[self.currentRadio][2]) < 0:
|
||||||
stdout=subprocess.PIPE,
|
commandline.insert(2, '-playlist')
|
||||||
stderr=subprocess.DEVNULL)
|
self.child = Popen(commandline,
|
||||||
signal.signal(signal.SIGCHLD, self.handler)
|
stdin =PIPE,
|
||||||
|
stdout=PIPE,
|
||||||
|
stderr=DEVNULL)
|
||||||
|
signal(SIGCHLD, self.handler)
|
||||||
self._flash = 0
|
self._flash = 0
|
||||||
self._paused = False
|
self._paused = False
|
||||||
self._buffered = ''
|
self._buffered = ''
|
||||||
self._buffering = 1
|
self._buffering = 1
|
||||||
self._cacheLevel = 0
|
self._cacheLevel = 0
|
||||||
import fcntl
|
flags = fcntl(self.child.stdout, F_GETFL)
|
||||||
flags = fcntl.fcntl(self.child.stdout, fcntl.F_GETFL)
|
fcntl(self.child.stdout, F_SETFL, flags | O_NONBLOCK)
|
||||||
fcntl.fcntl(self.child.stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK)
|
flags = fcntl(self.child.stdin, F_GETFL)
|
||||||
flags = fcntl.fcntl(self.child.stdin, fcntl.F_GETFL)
|
fcntl(self.child.stdin, F_SETFL, flags | O_NONBLOCK)
|
||||||
fcntl.fcntl(self.child.stdin, fcntl.F_SETFL, flags | os.O_NONBLOCK)
|
|
||||||
|
|
||||||
def stopPlayer(self):
|
def stopPlayer(self):
|
||||||
if self.child:
|
if self.child:
|
||||||
print(self._expectdying)
|
# print(self._expectdying)
|
||||||
self.child.stdin.write(b'q')
|
self.child.stdin.write(b'q')
|
||||||
|
self.child.stdin.flush()
|
||||||
self._expectdying += 1
|
self._expectdying += 1
|
||||||
self.child = None
|
self.child = None
|
||||||
|
|
||||||
def muteStream(self, event):
|
def muteStream(self, event):
|
||||||
if self.child and self._buffering == 0:
|
if self.child and self._buffering == 0:
|
||||||
self.child.stdin.write(b'm')
|
self.child.stdin.write(b'm')
|
||||||
|
self.child.stdin.flush()
|
||||||
self.putPattern(9*self._muting, 0, 9, 11, 30, 29)
|
self.putPattern(9*self._muting, 0, 9, 11, 30, 29)
|
||||||
self._muting = 1 - self._muting
|
self._muting = 1 - self._muting
|
||||||
|
|
||||||
@@ -128,6 +133,7 @@ class Application(wmoo.Application):
|
|||||||
def pauseStream(self, event):
|
def pauseStream(self, event):
|
||||||
if self.child and not self._buffering:
|
if self.child and not self._buffering:
|
||||||
self.child.stdin.write(b' ')
|
self.child.stdin.write(b' ')
|
||||||
|
self.child.stdin.flush()
|
||||||
self._paused = not self._paused
|
self._paused = not self._paused
|
||||||
if self._paused:
|
if self._paused:
|
||||||
self._colour = 1
|
self._colour = 1
|
||||||
@@ -163,8 +169,7 @@ class Application(wmoo.Application):
|
|||||||
return
|
return
|
||||||
self._count = 0
|
self._count = 0
|
||||||
if self.child:
|
if self.child:
|
||||||
import select
|
[i, o, e] = select([self.child.stdout], [], [], 0)
|
||||||
[i, o, e] = select.select([self.child.stdout], [], [], 0)
|
|
||||||
if i:
|
if i:
|
||||||
line = self.child.stdout.read(102400).decode("utf-8")
|
line = self.child.stdout.read(102400).decode("utf-8")
|
||||||
self._buffered += line
|
self._buffered += line
|
||||||
|
|||||||
@@ -16,3 +16,10 @@ bbcws rtsp://rmlive.bbc.co.uk/bbc-rbs/rmlive/ev7/live24/worldservice/liveinfent.
|
|||||||
bbc3 rtsp://rmlive.bbc.co.uk/bbc-rbs/rmlive/ev7/live24/radio3/live/r3_dsat_g2.ra 256
|
bbc3 rtsp://rmlive.bbc.co.uk/bbc-rbs/rmlive/ev7/live24/radio3/live/r3_dsat_g2.ra 256
|
||||||
bbc4 rtsp://rmlive.bbc.co.uk/bbc-rbs/rmlive/ev7/live24/radio4/live/r4_dsat_g2.ra 256
|
bbc4 rtsp://rmlive.bbc.co.uk/bbc-rbs/rmlive/ev7/live24/radio4/live/r4_dsat_g2.ra 256
|
||||||
|
|
||||||
|
# lines starting with # is ignored OR
|
||||||
|
# lines without exactly two tabs \t in it is ignored
|
||||||
|
# lines with \t<variable>\t<value> becomes a global variable
|
||||||
|
# lines with <name>\t<url>\t<bytes-cached> become a station
|
||||||
|
# <bytes-cached> must be 32 or larger
|
||||||
|
# positve <bytes-cached> ( 32) are stream urls
|
||||||
|
# negative <bytes-cached> (-32) are playlist urls
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from setuptools import setup, Extension
|
||||||
|
|
||||||
# Set these so they match your system.
|
# Set these so they match your system.
|
||||||
from __future__ import absolute_import
|
|
||||||
XLibDir = '/usr/lib/x11'
|
XLibDir = '/usr/lib/x11'
|
||||||
XIncludes = '/usr/include/x11'
|
XIncludes = '/usr/include/x11'
|
||||||
|
|
||||||
from setuptools import setup, Extension
|
# Changed 'wmdocklib.pywmgeneral' -> 'pywmdockapps.pywmgeneral'
|
||||||
|
# Changed source path 'wmdocklib/pywmgeneral.c' -> 'pywmdockapps/pywmgeneral.c'
|
||||||
pywmgeneral = Extension('wmdocklib.pywmgeneral',
|
pywmgeneral = Extension('wmdocklib.pywmgeneral',
|
||||||
libraries = ['Xpm', 'Xext', 'X11'],
|
libraries = ['Xpm', 'Xext', 'X11'],
|
||||||
library_dirs = [XLibDir],
|
library_dirs = [XLibDir],
|
||||||
@@ -16,7 +17,7 @@ pywmgeneral = Extension('wmdocklib.pywmgeneral',
|
|||||||
setup(
|
setup(
|
||||||
name="pywmdockapps",
|
name="pywmdockapps",
|
||||||
version = "$Revision: 1.99 $"[11:-2],
|
version = "$Revision: 1.99 $"[11:-2],
|
||||||
description="This helper functions for windowmaker dockapps\nRead the whole story at http://pywmdockapps.sourceforge.net/",
|
description="This helper functions for windowmaker dockapps",
|
||||||
author="Kristoffer Erlandsson & al.",
|
author="Kristoffer Erlandsson & al.",
|
||||||
author_email="mfrasca@zonnet.nl",
|
author_email="mfrasca@zonnet.nl",
|
||||||
url="http://pywmdockapps.sourceforge.net",
|
url="http://pywmdockapps.sourceforge.net",
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
"""\
|
"""
|
||||||
wmdocklib is a python module that will help you develop WindowMaker dockapps
|
pywmdockapps is a python module that will help you develop WindowMaker dockapps
|
||||||
in python. It is mostly a wrapper around the functions from the popular
|
in python. It is a wrapper around the functions from wmgeneral.c.
|
||||||
wmgeneral.c, but some new functions are added too.
|
|
||||||
|
|
||||||
to get help about a contained package, try:
|
To get help about a contained package, try:
|
||||||
help(wmdocklib.<name>)
|
help(pywmdockapps.<name>)
|
||||||
"""
|
"""
|
||||||
from .pywmgeneral import *
|
from .pywmgeneral import *
|
||||||
from .pywmhelpers import *
|
from .pywmhelpers import *
|
||||||
|
|
||||||
__all__ = ['wmoo']
|
# __all__ controls what 'from pywmdockapps import *' pulls in.
|
||||||
|
# If you want users to see 'pywmgeneral' and 'pywmhelpers' too, add them here.
|
||||||
|
__all__ = ['wmoo', 'pywmgeneral', 'pywmhelpers']
|
||||||
@@ -26,14 +26,14 @@ Some changes to handle the additional event handling in pywmgeneral
|
|||||||
First workingish version
|
First workingish version
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os, re
|
import os, re, sys
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
charset_start = None
|
charset_start = None
|
||||||
charset_width = None
|
charset_width = None
|
||||||
pattern_start = None
|
pattern_start = None
|
||||||
|
|
||||||
import wmdocklib.pywmgeneral as pywmgeneral
|
from . import pywmgeneral
|
||||||
defaultRGBFileList = [
|
defaultRGBFileList = [
|
||||||
'/etc/X11/rgb.txt',
|
'/etc/X11/rgb.txt',
|
||||||
'/usr/lib/X11/rgb.txt',
|
'/usr/lib/X11/rgb.txt',
|
||||||
@@ -145,7 +145,13 @@ def readXPM(fileName):
|
|||||||
Raise IOError if we run into trouble when trying to read the file. This
|
Raise IOError if we run into trouble when trying to read the file. This
|
||||||
function has not been tested extensively. do not try to use more than
|
function has not been tested extensively. do not try to use more than
|
||||||
"""
|
"""
|
||||||
with open(fileName, 'r') as f:
|
if hasattr(sys, '_MEIPASS'):
|
||||||
|
base_path = os.path.join(sys._MEIPASS, "wmdocklib")
|
||||||
|
else:
|
||||||
|
base_path = "wmdocklib"
|
||||||
|
filePath = os.path.join(base_path, fileName)
|
||||||
|
|
||||||
|
with open(filePath, 'r') as f:
|
||||||
lines = [l.rstrip('\n') for l in f.readlines()]
|
lines = [l.rstrip('\n') for l in f.readlines()]
|
||||||
s = ''.join(lines)
|
s = ''.join(lines)
|
||||||
res = []
|
res = []
|
||||||
@@ -436,7 +442,13 @@ def getColorCode(colorName, rgbFileName=None):
|
|||||||
if rgbFileName is None:
|
if rgbFileName is None:
|
||||||
raise ValueError('cannot find rgb file')
|
raise ValueError('cannot find rgb file')
|
||||||
|
|
||||||
with open(rgbFileName, 'r') as f:
|
if hasattr(sys, '_MEIPASS'):
|
||||||
|
base_path = os.path.join(sys._MEIPASS, "wmdocklib")
|
||||||
|
else:
|
||||||
|
base_path = "wmdocklib"
|
||||||
|
rgbFilePath = os.path.join(base_path, rgbFileName)
|
||||||
|
|
||||||
|
with open(rgbFilePath, 'r') as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
for l in lines:
|
for l in lines:
|
||||||
if l[0] != '!':
|
if l[0] != '!':
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
import sys, time
|
import sys, time
|
||||||
import wmdocklib.pywmhelpers as pywmhelpers
|
from . import pywmhelpers as pywmhelpers
|
||||||
import wmdocklib.pywmgeneral as pywmgeneral
|
from . import pywmgeneral as pywmgeneral
|
||||||
|
|
||||||
debug = 0
|
debug = 0
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user