aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-01-16 17:00:46 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2016-01-16 17:00:46 +0200
commitec44795f8ab3719c0d720a79efcc476d2499f259 (patch)
treea063c5e0cd162281c39007419f800d6a360f0129
parent4c31e7774d09fe1a59b6cfd692de4f4cade1899c (diff)
downloadmeson-ec44795f8ab3719c0d720a79efcc476d2499f259.zip
meson-ec44795f8ab3719c0d720a79efcc476d2499f259.tar.gz
meson-ec44795f8ab3719c0d720a79efcc476d2499f259.tar.bz2
Moved all wrap related things to their own submodule.
-rw-r--r--meson/interpreter.py2
-rw-r--r--meson/modules/__init__.py0
-rw-r--r--meson/wrap/wrap.py (renamed from meson/wrap.py)10
-rwxr-xr-xmeson/wrap/wraptool.py (renamed from wraptool.py)38
-rwxr-xr-xwraptool20
5 files changed, 46 insertions, 24 deletions
diff --git a/meson/interpreter.py b/meson/interpreter.py
index 1a28f3f..1a32998 100644
--- a/meson/interpreter.py
+++ b/meson/interpreter.py
@@ -19,7 +19,7 @@ from . import dependencies
from . import mlog
from . import build
from . import optinterpreter
-from . import wrap
+from .wrap import wrap
from . import mesonlib
import os, sys, platform, subprocess, shutil, uuid, re
diff --git a/meson/modules/__init__.py b/meson/modules/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/meson/modules/__init__.py
+++ /dev/null
diff --git a/meson/wrap.py b/meson/wrap/wrap.py
index ac9c9ce..2818fa0 100644
--- a/meson/wrap.py
+++ b/meson/wrap/wrap.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from . import mlog
+from .. import mlog
import urllib.request, os, hashlib, shutil
import subprocess
import sys
@@ -25,6 +25,14 @@ except ImportError:
has_ssl = False
API_ROOT = 'http://wrapdb.mesonbuild.com/v1/'
+def build_ssl_context():
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ ctx.options |= ssl.OP_NO_SSLv2
+ ctx.options |= ssl.OP_NO_SSLv3
+ ctx.verify_mode = ssl.CERT_REQUIRED
+ ctx.load_default_certs()
+ return ctx
+
def open_wrapdburl(urlstring):
global ssl_warning_printed
if has_ssl:
diff --git a/wraptool.py b/meson/wrap/wraptool.py
index 46860aa..d2f0a28 100755
--- a/wraptool.py
+++ b/meson/wrap/wraptool.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
-# Copyright 2015 The Meson development team
+# Copyright 2015-2016 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,11 +19,10 @@ import sys, os
import configparser
import shutil
-
-ssl_warning_printed = False
-
from glob import glob
+from .wrap import API_ROOT, open_wrapdburl
+
help_templ = '''This program allows you to manage your Wrap dependencies
using the online wrap database http://wrapdb.mesonbuild.com.
@@ -48,14 +47,6 @@ Commands:
def print_help():
print(help_templ % sys.argv[0])
-def build_ssl_context():
- ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
- ctx.options |= ssl.OP_NO_SSLv2
- ctx.options |= ssl.OP_NO_SSLv3
- ctx.verify_mode = ssl.CERT_REQUIRED
- ctx.load_default_certs()
- return ctx
-
def get_result(urlstring):
u = open_wrapdburl(urlstring)
data = u.read().decode('utf-8')
@@ -170,37 +161,40 @@ def status():
else:
print('', name, 'not up to date. Have %s %d, but %s %d is available.' % (current_branch, current_revision, latest_branch, latest_revision))
-if __name__ == '__main__':
- if len(sys.argv) < 2 or sys.argv[1] == '-h' or sys.argv[1] == '--help':
+def run(args):
+ if len(sys.argv) < 1 or sys.argv[0] == '-h' or sys.argv[1] == '--help':
print_help()
- sys.exit(0)
- command = sys.argv[1]
- args = sys.argv[2:]
+ return 0
+ command = args[0]
+ args = args[1:]
if command == 'list':
list_projects()
elif command == 'search':
if len(args) != 1:
print('Search requires exactly one argument.')
- sys.exit(1)
+ return 1
search(args[0])
elif command == 'install':
if len(args) != 1:
print('Install requires exactly one argument.')
- sys.exit(1)
+ return 1
install(args[0])
elif command == 'update':
if len(args) != 1:
print('update requires exactly one argument.')
- sys.exit(1)
+ return 1
update(args[0])
elif command == 'info':
if len(args) != 1:
print('info requires exactly one argument.')
- sys.exit(1)
+ return 1
info(args[0])
elif command == 'status':
status()
else:
print('Unknown command', command)
- sys.exit(1)
+ return 1
+ return 0
+if __name__ == '__main__':
+ sys.exit(run(sys.argv[1:]))
diff --git a/wraptool b/wraptool
new file mode 100755
index 0000000..46a2c26
--- /dev/null
+++ b/wraptool
@@ -0,0 +1,20 @@
+#!/usr/bin/env python3
+
+# Copyright 2016 The Meson development team
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+
+# http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from meson.wrap import wraptool
+import sys
+
+sys.exit(wraptool.run(sys.argv[1:])) \ No newline at end of file