Skip to content
This repository was archived by the owner on Jun 20, 2024. It is now read-only.

Commit ec59bfe

Browse files
Merge pull request #91 from mjdorma/1.3.0b1
1.3.0b1
2 parents 869787f + 5ded80d commit ec59bfe

File tree

11 files changed

+690
-53
lines changed

11 files changed

+690
-53
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,4 @@ ENV/
101101
*.swp
102102
*.zip
103103
*.xidl
104+
*.kmk

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ matrix:
1717
- python: 3.6
1818
env: TOXENV=packaging
1919

20+
# Building Library.py
21+
- python: 2.7
22+
env: TOXENV=build
23+
24+
- python: 3.6
25+
env: TOXENV=build
26+
2027
cache:
2128
- pip
2229
- directories:

CHANGES.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Changelog
22
=========
33

4+
version 1.3.0b1
5+
6+
* Added ``SettingsVersion.v1_17`` which is written by VirtualBox 5.2.x
7+
* Added ``VirtualBox.create_unattended_installer()``
8+
* Added ``IUnattended`` interface which can be used to create a Guest OS
9+
in a fully automated way. (Doesn't work yet in 5.2 beta)
10+
* Added ``IHostNetworkInterface.wireless`` property which returns
11+
``True`` if the interface is wireless.
12+
413
version 1.2.0 (28/08/2017)
514

615
* Searches for vboxapi installed in Anaconda on Windows. (@SethMichaelLarson PR #80)

build.py

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
77
"""
88
from xml.dom import minidom
9-
import pprint
10-
import sys
119
import os
1210
import re
1311
import hashlib
14-
import urllib2
12+
import requests
1513
import shutil
1614
import begin
1715

@@ -24,11 +22,17 @@
2422
def pythonic_name(name):
2523
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
2624
name = re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
27-
if hasattr(builtin, name) is True or name in ['global']:
25+
if hasattr(builtin, name) is True or name in ['global', 'file', 'apply']:
2826
name += "_p"
2927
return name
3028

3129

30+
def to_string(value):
31+
if isinstance(value, str):
32+
return value
33+
return value.decode('utf-8')
34+
35+
3236
LIB_IMPORTS = """\
3337
# A Pythonic VirtalBox Main API
3438
#
@@ -621,18 +625,18 @@ def preprocess(xidl, target):
621625
emit = True
622626
for line in xidl.splitlines():
623627
line = line.strip()
624-
if line.startswith('<if target='):
628+
if line.startswith(b'<if target='):
625629
if target in line:
626630
emit = True
627631
else:
628632
emit = False
629633
continue
630-
elif line == '</if>':
634+
elif line == b'</if>':
631635
emit = True
632636
continue
633637
if emit:
634638
lines.append(line)
635-
return "\n".join(lines)
639+
return b"\n".join(lines)
636640

637641

638642
###########################################################
@@ -645,13 +649,13 @@ def get_vbox_version(config_kmk):
645649
"Return the vbox config major, minor, build"
646650
with open(config_kmk, 'rb') as f:
647651
config = f.read()
648-
major = re.search("VBOX_VERSION_MAJOR = (?P<major>[\d])",
652+
major = re.search(b"VBOX_VERSION_MAJOR = (?P<major>[\d])",
649653
config).groupdict()['major']
650-
minor = re.search("VBOX_VERSION_MINOR = (?P<minor>[\d])",
654+
minor = re.search(b"VBOX_VERSION_MINOR = (?P<minor>[\d])",
651655
config).groupdict()['minor']
652-
build = re.search("VBOX_VERSION_BUILD = (?P<build>[\d])",
656+
build = re.search(b"VBOX_VERSION_BUILD = (?P<build>[\d])",
653657
config).groupdict()['build']
654-
return ".".join([major, minor, build])
658+
return b".".join([major, minor, build])
655659

656660
def download_master(downloads):
657661
print("Download the master xidl")
@@ -663,11 +667,11 @@ def download_master(downloads):
663667

664668
def download_stable(downloads):
665669
print("Download latest tarball for stable release then unpack xidl")
666-
url = urllib2.urlopen('https://www.virtualbox.org/wiki/Downloads')
667-
page = url.read()
670+
with requests.get('https://www.virtualbox.org/wiki/Downloads') as r:
671+
page = r.content
672+
668673
match = re.search("http://download.virtualbox.org/virtualbox/"
669-
"([0-9\.]+)/VirtualBox-([0-9\.]+).tar.bz2"
670-
, page)
674+
"([0-9\.]+)/VirtualBox-([0-9\.]+).tar.bz2", page)
671675
if not match:
672676
raise Exception("Failed to find source tarball url")
673677
sourceurl = page[match.start():match.end()]
@@ -710,7 +714,7 @@ def main(virtualbox_xidl='VirtualBox.xidl',
710714

711715
print("Create new virtualbox/library.py")
712716
xidl = open(virtualbox_xidl, 'rb').read()
713-
xidl = preprocess(xidl, target='xpidl')
717+
xidl = preprocess(xidl, target=b'xpidl')
714718

715719
xml = minidom.parseString(xidl)
716720

@@ -764,11 +768,11 @@ def main(virtualbox_xidl='VirtualBox.xidl',
764768
uuid = library.getAttribute('uuid')
765769
version = library.getAttribute('version')
766770
xidl_hash = hashlib.md5(xidl).hexdigest()
767-
lib_meta = LIB_META % dict(vbox_version=vbox_version,
768-
uuid=uuid,
769-
version=version,
770-
app_uuid=app_uuid,
771-
xidl_hash=xidl_hash)
771+
lib_meta = LIB_META % dict(vbox_version=to_string(vbox_version),
772+
uuid=to_string(uuid),
773+
version=to_string(version),
774+
app_uuid=to_string(app_uuid),
775+
xidl_hash=to_string(xidl_hash))
772776

773777
code = []
774778
code.append(LIB_IMPORTS)
@@ -778,14 +782,14 @@ def main(virtualbox_xidl='VirtualBox.xidl',
778782
code.extend(source['result'])
779783
code.extend(source['enum'])
780784
code.extend(source['interface'])
781-
code = "\n".join(code)
782-
print(" vbox version : %s" % vbox_version)
785+
code = b"\n".join([c.encode('utf-8') if not isinstance(c, bytes) else c for c in code])
786+
print(" vbox version : %s" % to_string(vbox_version))
783787
print(" xidl hash : %s" % xidl_hash)
784788
print(" version : %s" % version)
785-
print(" line count : %s" % code.count("\n"))
789+
print(" line count : %s" % code.count(b"\n"))
786790
library_path = os.path.join('.', 'virtualbox', 'library.py')
787791
if os.path.exists(library_path):
788792
os.unlink(library_path)
789-
with open(library_path, 'w') as f:
793+
with open(library_path, 'wb') as f:
790794
f.write(code)
791795

dev-requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
tox==2.7.0
22
flake8==3.3.0
33
Sphinx==1.6.1
4+
requests==2.18.3
5+
begins
6+
funconf

setup.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,23 @@
1212
tests_require = ['begins', 'funconf']
1313

1414

15-
def load_version(filename='./virtualbox/version.py'):
16-
"""Parse a __version__ number from a source file"""
17-
with open(filename) as source:
18-
text = source.read()
19-
match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", text)
20-
if not match:
21-
msg = "Unable to find version number in {}".format(filename)
22-
raise RuntimeError(msg)
23-
version = match.group(1)
24-
return version
15+
base_dir = os.path.dirname(os.path.abspath(__file__))
16+
about = {}
17+
with open(os.path.join(base_dir, 'virtualbox', '__about__.py')) as f:
18+
exec(f.read(), about)
2519

2620

2721
setup(
28-
name="pyvbox",
29-
version=load_version(),
22+
name=about['__name__'],
23+
version=about['__version__'],
3024
packages=["virtualbox",
3125
"virtualbox.library_ext"],
32-
author="Michael Dorman",
33-
author_email="mjdorma+pyvbox@gmail.com",
34-
url="https://github.com/mjdorma/pyvbox",
26+
author=about['__author__'],
27+
author_email=about['__email__'],
28+
url=about['__url__'],
3529
description="A complete VirtualBox Main API implementation",
3630
long_description=open('README.rst').read(),
37-
license="Apache-2.0",
31+
license=about['__license__'],
3832
zip_safe=False,
3933
install_requires=install_requires,
4034
platforms=['cygwin', 'win', 'linux'],

tox.ini

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = lint, docs, packaging
2+
envlist = lint, docs, packaging, build
33

44
[testenv:lint]
55
commands =
@@ -16,3 +16,8 @@ commands =
1616
python -m pip install readme_renderer check-manifest
1717
check-manifest --ignore *.yml,.github*
1818
python setup.py check --metadata --restructuredtext --strict
19+
20+
[testenv:build]
21+
commands =
22+
python -m pip install -r dev-requirements.txt
23+
python build.py --build-against-master --force-download

virtualbox/__about__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
__name__ = 'pyvbox'
2+
__author__ = 'Michael Dorman'
3+
__email__ = 'mjdorma+pyvbox@gmail.com'
4+
__version__ = '1.3.0b1'
5+
__license__ = 'Apache-2.0'
6+
__url__ = 'https://github.com/mjdorma/pyvbox'

virtualbox/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
from multiprocessing import current_process
2525

2626
from virtualbox.library_ext import library
27+
from .__about__ import (__name__, # noqa: F401
28+
__version__,
29+
__author__,
30+
__email__,
31+
__license__,
32+
__url__)
2733

2834

2935
# Adopt on the library API root documentation
@@ -238,5 +244,3 @@ def __init__(self, url='http://localhost/', user='', password=''):
238244
# Lazy include...
239245
from virtualbox import pool # noqa: F401
240246
from virtualbox import events # noqa: F401
241-
from virtualbox import version # noqa: F401
242-
from virtualbox.version import __version__ # noqa: F401

0 commit comments

Comments
 (0)