Skip to content

Commit

Permalink
Add memory usage support for Windows
Browse files Browse the repository at this point in the history
Using wmi wrapper for pywin32.
Testing py2exe sucks. If anyone else has a problem with a missing zope
module add an __init__.py to the site-packages\zope directory under the
interface directory and magic will happen.
  • Loading branch information
davidkassa committed Apr 25, 2013
1 parent 3a4a301 commit 65ef44d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
6 changes: 4 additions & 2 deletions README.md
Expand Up @@ -14,6 +14,8 @@ Windows:
* Install Python 2.7: http://www.python.org/getit/
* Install Twisted: http://twistedmatrix.com/trac/wiki/Downloads
* Install Zope.Interface: http://pypi.python.org/pypi/zope.interface/3.8.0
* Install python win32 api: http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/
* Install python win32 api wmi wrapper: https://pypi.python.org/pypi/WMI/#downloads
* Unzip the files into C:\Python27\Lib\site-packages

Running P2Pool:
Expand All @@ -32,14 +34,14 @@ router. Forward port 9333 to the host running P2Pool.
Run for additional options.

python run_p2pool.py --help

Donations towards further development:
-------------------------
1HNeqi3pJRNvXybNX4FKzZgYJsdTSqJTbk

Official wiki :
-------------------------
https://en.bitcoin.it/wiki/P2Pool
https://en.bitcoin.it/wiki/P2Pool

Alternate web front end :
-------------------------
Expand Down
20 changes: 13 additions & 7 deletions p2pool/util/memory.py
@@ -1,13 +1,19 @@
import gc
import os
import platform

_scale = {'kB': 1024, 'mB': 1024*1024,
'KB': 1024, 'MB': 1024*1024}

def resident():
with open('/proc/%d/status' % os.getpid()) as f:
v = f.read()
i = v.index('VmRSS:')
v = v[i:].split(None, 3)
#assert len(v) == 3, v
return float(v[1]) * _scale[v[2]]
if platform.system() == 'Windows':
from wmi import WMI
w = WMI('.')
result = w.query("SELECT WorkingSet FROM Win32_PerfRawData_PerfProc_Process WHERE IDProcess=%d" % os.getpid())
return int(result[0].WorkingSet)
else:
with open('/proc/%d/status' % os.getpid()) as f:
v = f.read()
i = v.index('VmRSS:')
v = v[i:].split(None, 3)
#assert len(v) == 3, v
return float(v[1]) * _scale[v[2]]
9 changes: 7 additions & 2 deletions setup.py
Expand Up @@ -5,6 +5,7 @@
import platform

from distutils.core import setup
from distutils.sysconfig import get_python_lib
import py2exe

version = __import__('p2pool').__version__
Expand All @@ -15,6 +16,8 @@
os.rename(os.path.join('p2pool', '__init__.py'), 'INITBAK')
try:
open(os.path.join('p2pool', '__init__.py'), 'wb').write('__version__ = %r%s%sDEBUG = False%s' % (version, os.linesep, os.linesep, os.linesep))
mfcdir = get_python_lib() + '\pythonwin\\'
mfcfiles = [os.path.join(mfcdir, i) for i in ["mfc90.dll", "mfc90u.dll", "mfcm90.dll", "mfcm90u.dll", "Microsoft.VC90.MFC.manifest"]]
bundle = 1
if im64:
bundle = bundle + 2
Expand All @@ -27,14 +30,16 @@
url='http://p2pool.forre.st/',
data_files=[
('', ['README.md']),
("Microsoft.VC90.MFC", mfcfiles),
('web-static', [
'web-static/d3.v2.min.js',
'web-static/favicon.ico',
'web-static/graphs.html',
'web-static/index.html',
'web-static/share.html',
]),
],

console=['run_p2pool.py'],
options=dict(py2exe=dict(
bundle_files=bundle,
Expand All @@ -50,7 +55,7 @@
win = '32'
if im64:
win = '64'

dir_name = 'p2pool_win' + win + '_' + version

if os.path.exists(dir_name):
Expand Down

0 comments on commit 65ef44d

Please sign in to comment.