Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python-mkp
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Container Registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
checkmk
python-mkp
Commits
d1682f56
Commit
d1682f56
authored
9 years ago
by
Thomas Reifenberger
Browse files
Options
Downloads
Patches
Plain Diff
Add dist function
parent
00d92cb7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mkp/__init__.py
+18
-0
18 additions, 0 deletions
mkp/__init__.py
test/integration/test_mkp.py
+51
-0
51 additions, 0 deletions
test/integration/test_mkp.py
with
69 additions
and
0 deletions
mkp/__init__.py
+
18
−
0
View file @
d1682f56
...
...
@@ -19,6 +19,24 @@ _DIRECTORIES = [
_VERSION_PACKAGED
=
'
python-mkp
'
_DIST_DIR
=
'
dist
'
def
dist
(
info
,
path
=
None
):
if
not
path
:
import
__main__
as
main
path
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
main
.
__file__
))
info
[
'
files
'
]
=
find_files
(
path
)
dist_dir
=
os
.
path
.
join
(
path
,
_DIST_DIR
)
filename
=
'
{}-{}.mkp
'
.
format
(
info
[
'
name
'
],
info
[
'
version
'
])
if
not
os
.
path
.
exists
(
dist_dir
):
os
.
makedirs
(
dist_dir
)
pack_to_file
(
info
,
path
,
os
.
path
.
join
(
dist_dir
,
filename
))
def
load_file
(
path
):
file_io
=
open
(
path
,
'
rb
'
)
return
Package
(
file_io
)
...
...
This diff is collapsed.
Click to expand it.
test/integration/test_mkp.py
+
51
−
0
View file @
d1682f56
...
...
@@ -128,3 +128,54 @@ def test_pack_and_unpack_covers_all_known_directories(tmpdir):
for
directory
in
DIRECTORIES
:
assert
dest
.
join
(
directory
,
'
test
'
).
exists
()
def
test_dist
(
tmpdir
):
tmpdir
.
join
(
'
agents
'
,
'
special
'
,
'
agent_test
'
).
write_binary
(
b
'
hello
'
,
ensure
=
True
)
tmpdir
.
join
(
'
checks
'
,
'
foo
'
).
write_binary
(
b
'
Check Me!
'
,
ensure
=
True
)
info
=
{
'
author
'
:
'
John Doe
'
,
'
name
'
:
'
foo
'
,
'
version
'
:
'
42
'
,
}
mkp
.
dist
(
info
,
str
(
tmpdir
))
assert
tmpdir
.
join
(
'
dist
'
,
'
foo-42.mkp
'
).
exists
()
package
=
mkp
.
load_file
(
str
(
tmpdir
.
join
(
'
dist
'
,
'
foo-42.mkp
'
)))
assert
package
.
info
[
'
author
'
]
==
'
John Doe
'
assert
package
.
info
[
'
name
'
]
==
'
foo
'
assert
package
.
info
[
'
files
'
][
'
agents
'
]
==
[
'
special/agent_test
'
]
assert
package
.
info
[
'
files
'
][
'
checks
'
]
==
[
'
foo
'
]
assert
package
.
info
[
'
version
'
]
==
'
42
'
assert
package
.
info
[
'
version.packaged
'
]
==
'
python-mkp
'
def
test_dist_uses_script_path_when_no_path_is_given
(
tmpdir
):
script
=
tmpdir
.
join
(
'
dist.py
'
)
script
.
write_text
(
u
'''
#!/usr/bin/env python
from mkp import dist
dist({
'
author
'
:
'
John Doe
'
,
'
name
'
:
'
foo
'
,
'
version
'
:
'
42
'
,
})
'''
,
'
utf-8
'
)
script
.
chmod
(
0700
)
tmpdir
.
join
(
'
agents
'
,
'
special
'
,
'
agent_test
'
).
write_binary
(
b
'
hello
'
,
ensure
=
True
)
tmpdir
.
join
(
'
checks
'
,
'
foo
'
).
write_binary
(
b
'
Check Me!
'
,
ensure
=
True
)
script
.
sysexec
()
assert
tmpdir
.
join
(
'
dist
'
,
'
foo-42.mkp
'
).
exists
()
package
=
mkp
.
load_file
(
str
(
tmpdir
.
join
(
'
dist
'
,
'
foo-42.mkp
'
)))
assert
package
.
info
[
'
author
'
]
==
'
John Doe
'
assert
package
.
info
[
'
name
'
]
==
'
foo
'
assert
package
.
info
[
'
files
'
][
'
agents
'
]
==
[
'
special/agent_test
'
]
assert
package
.
info
[
'
files
'
][
'
checks
'
]
==
[
'
foo
'
]
assert
package
.
info
[
'
version
'
]
==
'
42
'
assert
package
.
info
[
'
version.packaged
'
]
==
'
python-mkp
'
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment