Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.package
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xiaowu Zhang
slapos.package
Commits
65296116
Commit
65296116
authored
May 17, 2013
by
Jondy Zhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add testcase skeleton;
Add docs for netuse method;
parent
01dca258
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
6 deletions
+49
-6
windows/netreport/src/netuse.c
windows/netreport/src/netuse.c
+9
-6
windows/netreport/src/tests.py
windows/netreport/src/tests.py
+40
-0
No files found.
windows/netreport/src/netuse.c
View file @
65296116
...
@@ -134,6 +134,7 @@ netuse_user_info(PyObject *self, PyObject *args)
...
@@ -134,6 +134,7 @@ netuse_user_info(PyObject *self, PyObject *args)
static
PyObject
*
static
PyObject
*
netuse_map_drive
(
PyObject
*
self
,
PyObject
*
args
)
netuse_map_drive
(
PyObject
*
self
,
PyObject
*
args
)
{
{
PyErr_SetString
(
PyExc_RuntimeError
,
"Not Implemented"
);
return
NULL
;
return
NULL
;
}
}
...
@@ -144,8 +145,8 @@ netuse_usage_report(PyObject *self, PyObject *args)
...
@@ -144,8 +145,8 @@ netuse_usage_report(PyObject *self, PyObject *args)
PyObject
*
retvalue
=
NULL
;
PyObject
*
retvalue
=
NULL
;
DWORD
bitmasks
;
DWORD
bitmasks
;
char
chdrive
=
'@'
;
char
chdrive
=
'@'
;
char
drivepath
[
4
]
=
{
'A'
,
':'
,
'\\'
,
0
};
char
drivepath
[]
=
{
'A'
,
':'
,
'\\'
,
0
};
char
drivename
[
3
]
=
{
'A'
,
':'
,
0
};
char
drivename
[]
=
{
'A'
,
':'
,
0
};
ULARGE_INTEGER
lFreeBytesAvailable
;
ULARGE_INTEGER
lFreeBytesAvailable
;
ULARGE_INTEGER
lTotalNumberOfBytes
;
ULARGE_INTEGER
lTotalNumberOfBytes
;
ULARGE_INTEGER
lTotalNumberOfFreeBytes
;
ULARGE_INTEGER
lTotalNumberOfFreeBytes
;
...
@@ -198,7 +199,7 @@ netuse_usage_report(PyObject *self, PyObject *args)
...
@@ -198,7 +199,7 @@ netuse_usage_report(PyObject *self, PyObject *args)
&
cchBuff
&
cchBuff
);
);
if
(
dwResult
==
NO_ERROR
)
{
if
(
dwResult
==
NO_ERROR
)
{
if
(
server
name
)
{
if
(
server
len
)
{
if
((
cchBuff
<
serverlen
+
3
)
||
if
((
cchBuff
<
serverlen
+
3
)
||
(
strncmp
(
servername
,
szRemoteName
+
2
,
serverlen
)
!=
0
)
||
(
strncmp
(
servername
,
szRemoteName
+
2
,
serverlen
)
!=
0
)
||
(
szRemoteName
[
serverlen
+
2
]
!=
'\\'
)
(
szRemoteName
[
serverlen
+
2
]
!=
'\\'
)
...
@@ -282,9 +283,11 @@ static PyMethodDef NetUseMethods[] = {
...
@@ -282,9 +283,11 @@ static PyMethodDef NetUseMethods[] = {
netuse_usage_report
,
netuse_usage_report
,
METH_VARARGS
,
METH_VARARGS
,
(
(
"usagereport()
\n\n
"
"usagereport(servername='')
\n\n
"
"Return a tuple to report all the mapped drive information:
\n
"
"Return a tuple to report all the net drive information:
\n
"
"(user, domain, drive, usage, total).
\n
"
"(drive, remote, available, free, total).
\n
"
"If servername is not empty, then only net drives in the specified server
\n
"
"are returned.
\n
"
)
)
},
},
{
NULL
,
NULL
,
0
,
NULL
}
{
NULL
,
NULL
,
0
,
NULL
}
...
...
windows/netreport/src/tests.py
0 → 100755
View file @
65296116
# -*- coding: utf-8 -*-
import
sys
import
os
import
tempfile
import
shutil
import
netuse
import
unittest
class
BaseTestCase
(
unittest
.
TestCase
):
def
setUp
(
self
):
pass
def
tearDown
(
self
):
pass
class
NetUsageTests
(
BaseTestCase
):
def
test_user_info
(
self
):
u
=
netuse
.
userinfo
()
self
.
assertEquals
(
len
(
u
),
3
)
self
.
assertEquals
(
u
,
[])
def
test_usage_report
(
self
):
r
=
netuse
.
usagereport
()
self
.
assertEquals
(
len
(
r
),
0
)
self
.
assertEquals
(
r
,
[])
def
test_usage_report_server
(
self
):
r
=
netuse
.
usagereport
(
'myserver'
)
self
.
assertEquals
(
len
(
r
),
0
)
self
.
assertEquals
(
r
,
[])
if
__name__
==
"__main__"
:
# unittest.main()
loader
=
unittest
.
TestLoader
()
# loader.testMethodPrefix = 'test_'
suite
=
loader
.
loadTestsFromTestCase
(
NetUsageTests
)
unittest
.
TextTestRunner
(
verbosity
=
2
).
run
(
suite
)
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