Make most scripts work if we're in scripts/ directory.

See #213.
This commit is contained in:
Florian Bruhin 2014-10-26 19:42:01 +01:00
parent d3b1a5efb4
commit bb031b51f7
8 changed files with 31 additions and 1 deletions

View File

@ -61,6 +61,7 @@ def call_asciidoc(src, dst):
def main(colors=False):
"""Generate html files for the online documentation."""
utils.change_cwd()
utils.use_color = colors
asciidoc_files = [
('doc/FAQ.asciidoc', 'qutebrowser/html/doc/FAQ.html'),

View File

@ -27,6 +27,10 @@ import glob
import shutil
import fnmatch
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))
from scripts import utils
recursive_lint = ('__pycache__', '*.pyc')
lint = ('build', 'dist', 'pkg/pkg', 'pkg/qutebrowser-*.pkg.tar.xz', 'pkg/src',
@ -49,6 +53,7 @@ def remove(path):
def main():
"""Clean up lint in the current dir."""
utils.change_cwd()
for elem in lint:
for f in glob.glob(elem):
remove(f)

View File

@ -1,4 +1,9 @@
#!/bin/bash
if [[ $PWD == */scripts ]]; then
cd ..
fi
echo > crash.log
while :; do
exit=0

View File

@ -279,6 +279,7 @@ def _checker_enabled(args, group, name):
def main():
"""Main entry point."""
global config
utils.change_cwd()
read_files = config.read('.run_checks')
if not read_files:
raise IOError("Could not read config!")

View File

@ -31,6 +31,7 @@ import shutil
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))
import qutebrowser.qutebrowser # pylint: disable=unused-import
from scripts import utils
tempdir = tempfile.mkdtemp()

View File

@ -35,7 +35,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))
# We import qutebrowser.app so all @cmdutils-register decorators are run.
import qutebrowser.app
from scripts import asciidoc2html
from scripts import asciidoc2html, utils
from qutebrowser import qutebrowser
from qutebrowser.commands import cmdutils
from qutebrowser.config import configdata
@ -395,6 +395,7 @@ def regenerate_manpage(filename):
def main():
"""Regenerate all documentation."""
utils.change_cwd()
print("Generating manpage...")
regenerate_manpage('doc/qutebrowser.1.asciidoc')
print("Generating settings help...")

View File

@ -20,8 +20,16 @@
"""Update 3rd-party files (currently only ez_setup.py)."""
import sys
import os
import os.path
import urllib.request
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))
from scripts import utils
utils.change_cwd()
urllib.request.urlretrieve(
'https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py',
'scripts/ez_setup.py')

View File

@ -20,6 +20,7 @@
"""Utility functions for scripts."""
import os
import os.path
use_color = True
@ -82,3 +83,10 @@ def print_bold(text):
print(''.join([bold, text, reset]))
else:
print(text)
def change_cwd():
"""Change the scripts cwd if it was started inside the script folder."""
cwd = os.getcwd()
if os.path.split(cwd)[1] == 'scripts':
os.chdir(os.path.join(cwd, os.pardir))