placards 0.0.1__py3-none-any.whl
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.
- placards/__init__.py +0 -0
- placards/__main__.py +71 -0
- placards/__version__.py +1 -0
- placards/config.py +78 -0
- placards/errors.py +3 -0
- placards-0.0.1.dist-info/METADATA +14 -0
- placards-0.0.1.dist-info/RECORD +9 -0
- placards-0.0.1.dist-info/WHEEL +5 -0
- placards-0.0.1.dist-info/top_level.txt +1 -0
placards/__init__.py
ADDED
|
File without changes
|
placards/__main__.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import logging
|
|
3
|
+
import asyncio
|
|
4
|
+
|
|
5
|
+
import pyppeteer
|
|
6
|
+
from pyppeteer import launch
|
|
7
|
+
|
|
8
|
+
from placards import config
|
|
9
|
+
from placards.errors import ConfigError
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
LOGGER = logging.getLogger(__name__)
|
|
13
|
+
LOGGER.addHandler(logging.StreamHandler())
|
|
14
|
+
SERVER_URL = 'http://localhost:8000/'
|
|
15
|
+
|
|
16
|
+
CHROME_USER_DATA = os.getenv('CHROME_USER_DATA', '/tmp')
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
async def chrome():
|
|
20
|
+
browser = await launch(
|
|
21
|
+
headless=False,
|
|
22
|
+
args=[
|
|
23
|
+
#'--no-sandbox',
|
|
24
|
+
'--start-maximized',
|
|
25
|
+
'--start-fullscreen',
|
|
26
|
+
'--no-default-browser-check',
|
|
27
|
+
],
|
|
28
|
+
ignoreDefaultArgs=["--enable-automation"],
|
|
29
|
+
#dumpio=True,
|
|
30
|
+
executablePath='/usr/bin/google-chrome',
|
|
31
|
+
userDataDir=CHROME_USER_DATA,
|
|
32
|
+
defaultViewport=None,
|
|
33
|
+
autoClose=False,
|
|
34
|
+
)
|
|
35
|
+
pages = await browser.pages()
|
|
36
|
+
if len(pages):
|
|
37
|
+
page = pages[0]
|
|
38
|
+
else:
|
|
39
|
+
page = await browser.newPage()
|
|
40
|
+
return browser, page
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
async def goto(page, url):
|
|
44
|
+
page.setDefaultNavigationTimeout(0)
|
|
45
|
+
await page.goto(url, waitUntil='networkidle2')
|
|
46
|
+
#await page.keyboard.press('F11')
|
|
47
|
+
await page.screenshot({
|
|
48
|
+
'type': 'png',
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
async def main():
|
|
53
|
+
LOGGER.debug('Loading web client...')
|
|
54
|
+
|
|
55
|
+
try:
|
|
56
|
+
url = config.SERVER_URL
|
|
57
|
+
|
|
58
|
+
except ConfigError as e:
|
|
59
|
+
LOGGER.error('You must configure SERVER_URL in placard.ini!')
|
|
60
|
+
return
|
|
61
|
+
|
|
62
|
+
browser, page = await chrome()
|
|
63
|
+
await goto(page, url)
|
|
64
|
+
|
|
65
|
+
while not page.isClosed():
|
|
66
|
+
await asyncio.sleep(0.1)
|
|
67
|
+
|
|
68
|
+
await browser.close()
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
asyncio.run(main())
|
placards/__version__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '0.0.1'
|
placards/config.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import configparser
|
|
3
|
+
|
|
4
|
+
from os.path import isfile, expanduser, join as pathjoin
|
|
5
|
+
from types import ModuleType
|
|
6
|
+
|
|
7
|
+
from placards.errors import ConfigError
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
_NAME = 'placards.ini'
|
|
11
|
+
_DIRS = [
|
|
12
|
+
'./', '~/.placards/', '/etc/placards/',
|
|
13
|
+
]
|
|
14
|
+
_SECTION = 'placards'
|
|
15
|
+
_SENTINAL = object()
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _to_bool(s):
|
|
19
|
+
return s.lower() in ['1', 'yes', 'on', 'true']
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _read_config(paths=None):
|
|
23
|
+
if paths is None:
|
|
24
|
+
paths = [
|
|
25
|
+
expanduser(pathjoin(dir, _NAME)) for dir in _DIRS
|
|
26
|
+
]
|
|
27
|
+
parser = configparser.ConfigParser()
|
|
28
|
+
parser.read(paths)
|
|
29
|
+
return parser
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class _ConfigModule(ModuleType):
|
|
33
|
+
_config = None
|
|
34
|
+
|
|
35
|
+
def __getattribute__(self, name):
|
|
36
|
+
if name.startswith('_'):
|
|
37
|
+
raise AttributeError(name)
|
|
38
|
+
|
|
39
|
+
try:
|
|
40
|
+
return object.__getattribute__(self, name)
|
|
41
|
+
|
|
42
|
+
except AttributeError:
|
|
43
|
+
pass
|
|
44
|
+
|
|
45
|
+
config = object.__getattribute__(self, '_config')
|
|
46
|
+
if config is None:
|
|
47
|
+
config = _read_config()
|
|
48
|
+
setattr(self, '_config', config)
|
|
49
|
+
|
|
50
|
+
try:
|
|
51
|
+
value = config.get(_SECTION, name)
|
|
52
|
+
|
|
53
|
+
except configparser.NoOptionError:
|
|
54
|
+
raise ConfigError(name)
|
|
55
|
+
|
|
56
|
+
setattr(self, name, value)
|
|
57
|
+
return value
|
|
58
|
+
|
|
59
|
+
def get(self, name, default=_SENTINAL):
|
|
60
|
+
try:
|
|
61
|
+
return getattr(self, name)
|
|
62
|
+
|
|
63
|
+
except ConfigError as e:
|
|
64
|
+
if default is _SENTINAL:
|
|
65
|
+
raise
|
|
66
|
+
return default
|
|
67
|
+
|
|
68
|
+
def getint(self, name, default=_SENTINAL):
|
|
69
|
+
return int(self.getfloat(name, default))
|
|
70
|
+
|
|
71
|
+
def getfloat(self, name, default=_SENTINAL):
|
|
72
|
+
return float(self.get(name, default))
|
|
73
|
+
|
|
74
|
+
def getbool(self, name, default=_SENTINAL):
|
|
75
|
+
return _to_bool(self.get(name, default))
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
sys.modules[__name__].__class__ = _ConfigModule
|
placards/errors.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: placards
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A placards digital signage client for Linux in Python
|
|
5
|
+
Author: Ben Timby
|
|
6
|
+
Author-email: btimby@gmail.com
|
|
7
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
12
|
+
Requires-Dist: pyppeteer
|
|
13
|
+
|
|
14
|
+
Digital signage client using Pyppeteer to load resource in Chrome.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
placards/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
placards/__main__.py,sha256=ebf4AOm3oCr7ZEtC04E3GRWfaXMWjr-yWp1GqikhXK4,1555
|
|
3
|
+
placards/__version__.py,sha256=DsAHdxLC16H2VjdFOU5tBx2xT9VnNQ-XbTS24fRCa_w,22
|
|
4
|
+
placards/config.py,sha256=lFe6zv1Z5wfTeEb1UixNCiygjGjklcHOAgtcdZr3XY0,1785
|
|
5
|
+
placards/errors.py,sha256=BRq_SuJxyJbC8NEpKp__mKTw4AzNWpSALU90hEaxKY8,85
|
|
6
|
+
placards-0.0.1.dist-info/METADATA,sha256=ooAwxPVmVgE05Pc8OnaK_hXgZltVRXGfnQoLzEEkKa8,506
|
|
7
|
+
placards-0.0.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
8
|
+
placards-0.0.1.dist-info/top_level.txt,sha256=3fMmfVtlJBAZa-VO6cSHrpzV2hRLor5TKTvPf-2JV7o,9
|
|
9
|
+
placards-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
placards
|