Commit 6ccaa7f9 authored by Jondy Zhao's avatar Jondy Zhao

Add skeleton files of net usage report

parent aa7a0e43
Net Resource Usage Report For Windows
#!/usr/bin/env python
#
import sys
import os
try:
from setuptools import setup, Extension
except ImportError:
from distutils.core import setup, Extension
def get_description():
README = os.path.abspath(os.path.join(os.path.dirname(__file__), 'README'))
f = open(README, 'r')
try:
return f.read()
finally:
f.close()
VERSION = "0.1.1"
if sys.platform.startswith("cygwin"):
def get_winver():
return '0x0503'
maj, min = sys.getwindowsversion()[0:2]
return '0x0%s' % ((maj * 100) + min)
extensions = [Extension('netuse',
sources=['src/netuse.c'],
define_macros=[('_WIN32_WINNT', '0x0503'),
('USE_SYS_TYPES_FD_SET', 1)],
libraries=["psapi", "kernel32", "advapi32",
"shell32", "netapi32", "iphlpapi",
"wtsapi32"],
#extra_compile_args=["/Z7"],
#extra_link_args=["/DEBUG"]
)]
else:
sys.exit('platform %s is not supported' % sys.platform)
def main():
setup_args = dict(
name='netreport',
version=VERSION,
download_url='http://',
description='A tool used to report the usage of net resource in the Windows',
long_description=get_description(),
keywords=['netdrive',],
scripts=['src/netreport.py'],
author='Nexedi',
author_email='jondy.zhao@nexedi.com',
maintainer='Jondy Zhao',
maintainer_email='jondy.zhao@nexedi.com',
url='http://',
platforms='Platform Independent',
license='License :: OSI Approved :: BSD License',
)
if extensions is not None:
setup_args["ext_modules"] = extensions
setup(**setup_args)
if __name__ == '__main__':
main()
/*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <Python.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/cygwin.h>
/* Avoid select function conflict in the winsock2.h */
#define __INSIDE_CYGWIN__
#include <windows.h>
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
#define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
static PyObject *
netuse_init(PyObject *self, PyObject *args)
{
return NULL;
}
static PyMethodDef NetUseMethods[] = {
{
"init",
netuse_init,
METH_VARARGS,
(
"init()\n\n"
"Initialize an inotify instance and return a PyCObject, When this\n"
"PyCObject is reclaimed, GC will free the memory.\n"
)
},
{NULL, NULL, 0, NULL}
};
PyMODINIT_FUNC netuse(void)
{
PyObject* module;
module = Py_InitModule3("netuse",
NetUseMethods,
"Show information about net resource in the Windows."
);
if (module == NULL)
return;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment