Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
f86db3a4
Commit
f86db3a4
authored
Jun 19, 2014
by
Chris Church
Committed by
Matt Martz
Jun 19, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update slurp/win_ping/win_stat to use Get-Attr.
parent
e5399b12
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
49 deletions
+20
-49
library/windows/slurp.ps1
+16
-34
library/windows/win_ping.ps1
+2
-5
library/windows/win_stat.ps1
+2
-10
No files found.
library/windows/slurp.ps1
View file @
f86db3a4
...
...
@@ -19,46 +19,28 @@
$params
=
Parse-Args
$args
;
$src
=
''
;
If
(
$params
.src.GetType
)
{
$src
=
$params
.src;
}
Else
{
If
(
$params
.path.GetType
)
{
$src
=
$params
.path;
}
}
$src
=
Get-Attr
$params
"src"
(
Get-Attr
$params
"path"
$FALSE
)
;
If
(
-not
$src
)
{
$result
=
New-Object
psobject @
{}
;
Fail-Json
$result
"missing required argument: src"
;
Fail-Json
(
New-Object
psobject
)
"missing required argument: src"
;
}
If
(
Test-Path
$src
)
If
(
Test-Path
-PathType Leaf
$src
)
{
If
((
Get-Item
$src
)
.Directory
)
# Only files have the .Directory attribute.
{
$bytes
=
[
System.IO.File]::ReadAllBytes
(
$src
)
;
$content
=
[
System.Convert]::ToBase64String
(
$bytes
)
;
$result
=
New-Object
psobject @
{
changed
=
$false
encoding
=
"base64"
}
;
Set
-Attr
$result
"content"
$content
;
Exit
-Json
$result
;
}
Else
{
$result
=
New-Object
psobject @
{}
;
Fail-Json
$result
(
"is a directory: "
+
$src
)
;
}
$bytes
=
[
System.IO.File]::ReadAllBytes
(
$src
)
;
$content
=
[
System.Convert]::ToBase64String
(
$bytes
)
;
$result
=
New-Object
psobject @
{
changed
=
$false
encoding
=
"base64"
content
=
$content
}
;
Exit
-Json
$result
;
}
ElseIf
(
Test-Path
-PathType Container
$src
)
{
Fail-Json
(
New-Object
psobject
)
(
"is a directory: "
+
$src
)
;
}
Else
{
$result
=
New-Object
psobject @
{}
;
Fail-Json
$result
(
"file not found: "
+
$src
)
;
Fail-Json
(
New-Object
psobject
)
(
"file not found: "
+
$src
)
;
}
library/windows/win_ping.ps1
View file @
f86db3a4
...
...
@@ -19,14 +19,11 @@
$params
=
Parse-Args
$args
;
$data
=
'pong'
;
If
(
$params
.data.GetType
)
{
$data
=
$params
.data;
}
$data
=
Get-Attr
$params
"data"
"pong"
;
$result
=
New-Object
psobject @
{
changed
=
$false
ping
=
$data
}
;
Exit
-Json
$result
;
library/windows/win_stat.ps1
View file @
f86db3a4
...
...
@@ -19,21 +19,13 @@
$params
=
Parse-Args
$args
;
$path
=
$FALSE
;
If
(
$params
.path.GetType
)
{
$path
=
$params
.path;
}
$path
=
Get-Attr
$params
"path"
$FALSE
;
If
(
$path
-eq
$FALSE
)
{
Fail-Json
(
New-Object
psobject
)
"missing required argument: path"
;
}
$get_md5
=
$TRUE
;
If
(
$params
.get_md5.GetType
)
{
$get_md5
=
$params
.get_md5 | ConvertTo-Bool;
}
$get_md5
=
Get-Attr
$params
"get_md5"
$TRUE
| ConvertTo-Bool;
$result
=
New-Object
psobject @
{
stat
=
New-Object
psobject
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment