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
51a50dee
Commit
51a50dee
authored
Jun 18, 2014
by
Matt Martz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up how we initialize the result psobject
parent
bf400d3c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
16 deletions
+21
-16
library/windows/slurp.ps1
+4
-2
library/windows/win_ping.ps1
+4
-2
library/windows/win_stat.ps1
+13
-12
No files found.
library/windows/slurp.ps1
View file @
51a50dee
...
...
@@ -39,7 +39,9 @@ If (-not $src)
$bytes
=
[
System.IO.File]::ReadAllBytes
(
$src
)
;
$content
=
[
System.Convert]::ToBase64String
(
$bytes
)
;
$result
=
New-Object
psobject;
$result
=
New-Object
psobject @
{
changed
=
$false
encoding
=
"base64"
}
;
Set
-Attr
$result
"content"
$content
;
Set
-Attr
$result
"encoding"
"base64"
;
echo
$result
|
ConvertTo-Json
;
library/windows/win_ping.ps1
View file @
51a50dee
...
...
@@ -25,6 +25,8 @@ If ($params.data.GetType)
$data
=
$params
.data;
}
$result
=
New-Object
psobject;
Set
-Attr
$result
"ping"
$data
;
$result
=
New-Object
psobject @
{
changed
=
$false
ping
=
$data
}
;
echo
$result
|
ConvertTo-Json
;
library/windows/win_stat.ps1
View file @
51a50dee
...
...
@@ -28,36 +28,37 @@ If ($params.path.GetType)
$get_md5
=
$TRUE
;
If
(
$params
.get_md5.GetType
)
{
$get_md5
=
$params
.get_md5;
$get_md5
=
$params
.get_md5;
}
$stat
=
New-Object
psobject;
$result
=
New-Object
psobject @
{
stat
=
New-Object
psobject
changed
=
$false
}
;
If
(
Test-Path
$path
)
{
Set
-Attr
$stat
"exists"
$TRUE
;
Set
-Attr
$
result
.
stat
"exists"
$TRUE
;
$info
=
Get-Item
$path
;
If
(
$info
.Directory
)
# Only files have the .Directory attribute.
{
Set
-Attr
$stat
"isdir"
$FALSE
;
Set
-Attr
$stat
"size"
$info
.Length;
Set
-Attr
$
result
.
stat
"isdir"
$FALSE
;
Set
-Attr
$
result
.
stat
"size"
$info
.Length;
}
Else
{
Set
-Attr
$stat
"isdir"
$TRUE
;
Set
-Attr
$
result
.
stat
"isdir"
$TRUE
;
}
}
Else
{
Set
-Attr
$stat
"exists"
$FALSE
;
Set
-Attr
$
result
.
stat
"exists"
$FALSE
;
}
If
(
$get_md5
-and
$
stat
.exists -and -not
$
stat
.isdir
)
If
(
$get_md5
-and
$
result
.stat.exists -and -not
$result
.
stat.isdir
)
{
$path_md5
=
(
Get-FileHash
-Path
$path
-Algorithm MD5
)
.Hash.ToLower
()
;
Set
-Attr
$stat
"md5"
$path_md5
;
Set
-Attr
$
result
.
stat
"md5"
$path_md5
;
}
$result
=
New-Object
psobject;
Set
-Attr
$result
"stat"
$stat
;
Set
-Attr
$result
"changed"
$FALSE
;
echo
$result
|
ConvertTo-Json
;
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