johnscillieri / psutil-nim Goto Github PK
View Code? Open in Web Editor NEWPort of python psutil to nim
License: MIT License
Port of python psutil to nim
License: MIT License
I was testing the script disk_usage.nim
When compiled with 64bit it works, however, with 32bit gives the error
/opt/psutil-nim/scripts/disk_usage.nim(34) disk_usage
/opt/psutil-nim/scripts/disk_usage.nim(26) main
/home/kittytechno/.nimble/pkgs/psutil-0.6.0/psutil/psutil_posix.nim(206) disk_usage
/home/kittytechno/.choosenim/toolchains/nim-1.2.0/lib/system/fatal.nim(49) sysFatal
Error: unhandled exception: over- or underflow [OverflowError]
The lib is importing a linux library in windows, so it gives a C-level error:
C:\Users\Administrator\nimcache\test_r\@m..@s..@s..@s..@sUsers@sAdministrator@s.
nimble@[email protected]@spsutil@spsutil_windows.nim.c:10:10: fatal error: sys
/socket.h: No such file or directory
10 | #include <sys/socket.h>
| ^~~~~~~~~~~~~~
compilation terminated.
z@z ~/.n/p/psutil-0.5.0> nim c psutil_posix.nim
Hint: used config file '/home/z/Nim/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: psutil_posix [Processing]
Hint: posix [Processing]
Hint: times [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: math [Processing]
Hint: algorithm [Processing]
Hint: tables [Processing]
Hint: hashes [Processing]
Hint: common [Processing]
Hint: nativesockets [Processing]
Hint: os [Processing]
Hint: ospaths [Processing]
Hint: options [Processing]
Hint: typetraits [Processing]
psutil_posix.nim(89, 24) Error: type mismatch: got (int, int literal(0))
but expected one of:
proc kill(a1: Pid; a2: cint): cint
/Users/tester/.nimble/pkgs2/psutil-0.6.0-965ce8f561bbbd908402979a36bb3eac5cc50897/psutil/psutil_posix.nim(55, 47) Error: invalid indentation
after I import psutil and I got the above error, using nim2.0.0
Hello,
There was a backward incompatible change in nim 1.0.0 that removed isDigit
for string args.
So with newer nim versions, this fails:
git clone https://github.com/johnscillieri/psutil-nim psutil
cd psutil
nim c -r tests/test_posix.nim
psutil/src/psutil/psutil_linux.nim(158, 47) Error: type mismatch: got <string>
but expected one of:
proc isDigit(c: char): bool
first type mismatch at position: 1
required type for c: char
but expression 'it.path' is of type: string
expression: isdigit(it.path)
Is this project discontinued? May it even be finished?
Thanks!
Type Issues in Windows side of psutil. I assume something changed in winim but I am uncertain.
Linux compiles and runs without issues.
Nim Version
nim -v
Nim Compiler Version 1.4.4 [Windows: amd64]
Compiled at 2021-02-23
Copyright (c) 2006-2020 by Andreas Rumpf
active boot switches: -d:release
winim version
nimble install winim
Downloading https://github.com/khchen/winim using git
Verifying dependencies for [email protected]
Installing [email protected]
Building winim/winim/winimx.exe using c backend
Prompt: [email protected] already exists. Overwrite? [y/N]
Answer: N
psutil version
nimble install psutil
Downloading https://github.com/juancarlospaco/psutil-nim using git
Verifying dependencies for [email protected]
Installing [email protected]
Prompt: [email protected] already exists. Overwrite? [y/N]
Answer: N
compilation output
C:\Users\user\processlist>nim c mytest.nim
Hint: used config file 'C:\nim-1.4.4\config\nim.cfg' [Conf]
Hint: used config file 'C:\nim-1.4.4\config\config.nims' [Conf]
...................................................................................................
C:\Users\user\.nimble\pkgs\psutil-0.6.0\psutil\psutil_windows.nim(151, 30) Error: type mismatch: got <HANDLE, HMODULE, array[0..259, TCHAR], DWORD>
but expected one of:
proc GetModuleBaseName(hProcess: HANDLE; hModule: HMODULE; lpBaseName: LPWSTR;
nSize: DWORD): DWORD
first type mismatch at position: 3
required type for lpBaseName: LPWSTR
but expression 'szProcessName' is of type: array[0..259, TCHAR]
expression: GetModuleBaseName(hProcess, hMod, szProcessName, cast[DWORD](len(szProcessName)))
The issues are not limited to this proc. I tried to run down my list of issues that I had as a result of trying to create a windows process list. Unfortunately the type issues go a bit deeper than I understand at this point.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.