forked from LBRYCommunity/lbry-sdk
Add missing files
Somehow these files got lost in a rebase. I'm sort of at a loss for how, but well, adding them back in.
This commit is contained in:
parent
37fee71898
commit
f3a71245e8
4 changed files with 113 additions and 0 deletions
29
packaging/append_sha_to_version.py
Normal file
29
packaging/append_sha_to_version.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
import argparse
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
def main(args=None):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('filename')
|
||||
parser.add_argument('commit')
|
||||
args = parser.parse_args(args)
|
||||
|
||||
with open(args.filename) as f:
|
||||
contents = f.read()
|
||||
|
||||
commit = args.commit[:7]
|
||||
|
||||
new_contents = re.sub(
|
||||
r'^__version__ = [\'"](.*)[\'"]$',
|
||||
r'__version__ = "\1-{}"'.format(commit),
|
||||
contents,
|
||||
flags=re.MULTILINE,
|
||||
)
|
||||
|
||||
with open(args.filename, 'w') as f:
|
||||
f.write(new_contents)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
15
packaging/travis/setup_qa.sh
Executable file
15
packaging/travis/setup_qa.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Configure the library for a non-production release
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
set -o xtrace
|
||||
|
||||
|
||||
# changes here also need to be added to build.ps1 for windows
|
||||
python packaging/append_sha_to_version.py lbrynet/__init__.py ${TRAVIS_COMMIT}
|
||||
|
||||
wget https://s3.amazonaws.com/lbry-ui/development/dist.zip -O dist.zip
|
||||
unzip -oq dist.zip -d lbrynet/resources/ui
|
||||
wget https://s3.amazonaws.com/lbry-ui/development/data.json -O lbrynet/resources/ui/data.json
|
16
packaging/windows/build.ps1
Normal file
16
packaging/windows/build.ps1
Normal file
|
@ -0,0 +1,16 @@
|
|||
# this is a port of setup_qa.sh used for the unix platforms
|
||||
If (${Env:APPVEYOR_REPO_TAG} -NotMatch "true") {
|
||||
C:\Python27\python.exe packaging\append_sha_to_version.py lbrynet\__init__.py ${Env:APPVEYOR_REPO_COMMIT}
|
||||
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
|
||||
wget https://s3.amazonaws.com/lbry-ui/development/dist.zip -OutFile dist.zip
|
||||
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
|
||||
Expand-Archive dist.zip -dest lbrynet\resources\ui
|
||||
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
|
||||
wget https://s3.amazonaws.com/lbry-ui/development/data.json -OutFile lbrynet\resources\ui\data.json
|
||||
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
|
||||
}
|
||||
|
||||
C:\Python27\python.exe setup.py build bdist_msi
|
||||
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
|
||||
|
||||
signtool.exe sign /f packaging\windows\certs\lbry2.pfx /p %key_pass% /tr http://tsa.starfieldtech.com /td SHA256 /fd SHA256 dist\*.msi
|
53
tests/unit/lbrynet_daemon/test_UIManager.py
Normal file
53
tests/unit/lbrynet_daemon/test_UIManager.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
import json
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
from twisted.trial import unittest
|
||||
import mock
|
||||
|
||||
from lbrynet.lbrynet_daemon import UIManager
|
||||
|
||||
|
||||
class BundledUIManagerTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.active_dir = tempfile.mkdtemp()
|
||||
self.bundled_dir = tempfile.mkdtemp()
|
||||
self.manager = UIManager.BundledUIManager(mock.Mock(), self.active_dir, self.bundled_dir)
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.active_dir)
|
||||
shutil.rmtree(self.bundled_dir)
|
||||
|
||||
def test_when_bundle_is_not_available(self):
|
||||
result = self.manager.setup()
|
||||
self.assertFalse(result)
|
||||
expected = []
|
||||
self.assertEqual(os.listdir(self.active_dir), expected)
|
||||
|
||||
def test_when_already_bundled(self):
|
||||
make_data_file(self.active_dir)
|
||||
make_data_file(self.bundled_dir)
|
||||
result = self.manager.setup()
|
||||
self.assertTrue(result)
|
||||
expected = ['data.json']
|
||||
self.assertEqual(os.listdir(self.active_dir), expected)
|
||||
|
||||
def test_bundled_files_are_copied(self):
|
||||
make_data_file(self.active_dir)
|
||||
make_data_file(self.bundled_dir, 'BARFOO')
|
||||
touch(os.path.join(self.bundled_dir, 'test.html'))
|
||||
result = self.manager.setup()
|
||||
self.assertTrue(result)
|
||||
expected = ['data.json', 'test.html']
|
||||
self.assertItemsEqual(os.listdir(self.active_dir), expected)
|
||||
|
||||
|
||||
def make_data_file(directory, sha='FOOBAR'):
|
||||
with open(os.path.join(directory, 'data.json'), 'w') as f:
|
||||
json.dump({'sha': sha}, f)
|
||||
|
||||
|
||||
def touch(filename):
|
||||
with open(filename, 'a') as f:
|
||||
pass
|
Loading…
Reference in a new issue