Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wordcloud can't generate a word cloud #9

Open
zaphbbrox opened this issue Aug 20, 2019 · 13 comments
Open

Wordcloud can't generate a word cloud #9

zaphbbrox opened this issue Aug 20, 2019 · 13 comments
Labels
bug Something isn't working compatibility Issue is related to compatibility.

Comments

@zaphbbrox
Copy link

Hey,
since I'm not using it on a Mac but on a Manjaro system, I opened a new issue.
Besides that I have very similiar issues like in #8 :

$ ./updateWallpaper.sh
Traceback (most recent call last):
  File "generateWallpaper.py", line 50, in <module>
    ).generate_from_frequencies(resourceDict)
  File "/home/user/.local/lib/python3.7/site-packages/wordcloud/wordcloud.py", line 383, in generate_from_frequencies
    "got %d." % len(frequencies))
ValueError: We need at least 1 word to plot a word cloud, got 0.

I noticed that running top -b -n 1 only gives me the running processes, but even when I change it to top -b -n 1 -i to show the last remembered state in updateWallpaper.sh the error is the same.
I'm not sure what causes this.. Maybe a different version of top?
My system uses procps-ng 3.3.15.

And my top.out:

top - 16:21:32 up 57 min,  5 users,  load average: 0,70, 0,53, 0,47
Tasks: 191 total,   1 running, 190 sleeping,   0 stopped,   0 zombie
%CPU0  :  0,0 us,  0,0 sy,  0,0 ni, 94,4 id,  0,0 wa,  5,6 hi,  0,0 si,  0,0 st
%CPU1  :  0,0 us,  0,0 sy,  0,0 ni,100,0 id,  0,0 wa,  0,0 hi,  0,0 si,  0,0 st
%CPU2  :  5,6 us, 11,1 sy,  0,0 ni, 83,3 id,  0,0 wa,  0,0 hi,  0,0 si,  0,0 st
%CPU3  :  5,3 us,  5,3 sy,  0,0 ni, 89,5 id,  0,0 wa,  0,0 hi,  0,0 si,  0,0 st
KiB Spch:  5982776 total,  2809516 free,  1365032 used,  1808228 buff/cache
KiB Swap:  6991868 total,  6991868 free,        0 used.  4012360 avail Spch

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     ZEIT+ BEFEHL
 4533 user    20       13856   4072   3344 R  18,8   0,1   0:00.03 top -b -i -n 1 -u user
  565 user    20       31420   8840   7284 S         0,1   0:00.09 /usr/lib/systemd/systemd --user
  566 user    20       73432   2660     44 S         0,0           (sd-pam)
  576 user    20      297288  40076  35448 S         0,7   0:00.75 /usr/bin/kwalletd5 --pam-login 7 3
  577 user    20        7436   3308   2844 S         0,1   0:00.04 /bin/sh /usr/bin/startkde
  585 user    20       11100   4628   3612 S         0,1   0:00.55 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
  610 user    20        2200     84        S         0,0           /usr/lib/kf5/start_kdeinit --kded +kcminit_startup
  613 user    20      109448  20124  16952 S         0,3   0:00.15 kdeinit5: Running...
  614 user    20      296644  40248  35712 S         0,7   0:00.83 /usr/lib/kf5/klauncher --fd=9
  617 user    20      866540  60252  49988 S         1,0   0:03.36 kded5 [kdeinit5]
  624 user    20      307088  41032  36280 S         0,7   0:01.21 /usr/bin/kaccess
  636 user    20      296096  38476  33264 S         0,6   0:00.83 /usr/bin/kglobalaccel5
  642 user    20      156876   5172   4644 S         0,1           /usr/lib/dconf-service
  647 user    20       52204   7344   6764 S         0,1           kwrapper5 /usr/bin/ksmserver
  649 user    20      385960  45360  39764 S         0,8   0:01.07 /usr/bin/ksmserver
  652 user    20      232052  19476  17532 S         0,3   0:00.51 /usr/lib/kf5/kscreen_backend_launcher
  663 user    20     2967648 114728  75576 S         1,9   1:30.77 /usr/bin/kwin_x11 -session 10d6616765000156271349000000008530007_1566300741_407616
  671 user    39  19  256,3g 483468 305248 S         8,1   0:08.73 /usr/bin/baloo_file
  674 user    20      512176  73752  57664 S         1,2   0:02.20 /usr/bin/krunner
  677 user    20     1554044 279172 120160 S         4,7   1:33.18 /usr/bin/plasmashell
  683 user    20      446880  42404  37552 S         0,7   0:00.71 /usr/lib/polkit-kde-authentication-agent-1
  688 user    20      238868  20972  18844 S         0,4   0:00.56 /usr/bin/xembedsniproxy
  694 user    20      240012  22320  20180 S         0,4   0:00.51 /usr/bin/gmenudbusmenuproxy
  696 user    20      397880  57984  50216 S         1,0   0:01.52 /usr/lib/kdeconnectd
  704 user     9 -11  840800  12880   9420 S         0,2   0:00.16 /usr/bin/pulseaudio --daemonize=no
  741 user    20      558052  35220  31100 S         0,6   0:00.82 /usr/lib/kactivitymanagerd
  747 user    20      247308   6864   5992 S         0,1   0:00.01 /usr/lib/pulse/gsettings-helper
  757 user    20      431468  75656  59704 S         1,3   0:23.94 /usr/bin/yakuake -session 10d6616765000156271349000000008530008_1566300741_389646
  766 user    20      307416  45812  39244 S         0,8   0:01.66 /usr/bin/msm_kde_notifier -session 10d6616765000156271349000000008530009_1566300741_388300
  770 user    20      320796  48328  42444 S         0,8   0:00.83 /usr/bin/octopi-notifier -session 10d6616765000156271349200000008530012_1566300741_388268
  779 user    20       13904   9100   4672 S         0,2   0:03.42 /usr/bin/zsh
  781 user    20     1107360 102212  78308 S         1,7   0:05.33 /usr/bin/nextcloud -session 10d6616765000156340972400000010330012_1566300741_388443
  827 user    20        4028   2344   2136 S         0,0   0:06.43 /usr/bin/ksysguardd
 1054 user    20      235396   4776   4340 S         0,1   0:00.01 /usr/lib/geoclue-2.0/demos/agent
 1067 user    20      420864  40440  35896 S         0,7   0:00.94 /usr/lib/org_kde_powerdevil
 1103 user    20       45244   6872   6228 S         0,1   0:00.02 /usr/lib/bluetooth/obexd
 1105 user    20      434084  82008  40092 S         1,4   0:01.55 /usr/bin/python /usr/bin/vorta -session 10d6616765000156341015000000010330022_1566300741_388200 -name vorta
 1113 user    20      110096  17688  14476 S         0,3   0:00.01 file.so [kdeinit5] file local:/run/user/1000/klauncherHxprTy.1.slave-socket local:/run/user/1000/kio_desktopdEmnga+
 1211 user    20     1037504 225336 126024 S         3,8   1:56.41 /opt/vivaldi/vivaldi-bin https://github.com/anirudhajith/process-wallpaper/blob/master/README.md
 1220 user    20       14092   1676   1416 S         0,0           cat
 1221 user    20       14092   1592   1336 S         0,0           cat
 1223 user    20        2748    884    788 S         0,0           /opt/vivaldi/vivaldi-sandbox /opt/vivaldi/vivaldi-bin --type=zygote
 1224 user    20      237384  47248  38244 S         0,8   0:00.06 /opt/vivaldi/vivaldi-bin --type=zygote
 1226 user    20      237384  13604   4588 S         0,2   0:00.04 /opt/vivaldi/vivaldi-bin --type=zygote
 1236 user    20      238476   7628   6704 S         0,1   0:00.03 /usr/lib/gvfsd
 1241 user    20      379096   6016   5220 S         0,1   0:00.07 /usr/lib/gvfsd-fuse /run/user/1000/gvfs -f -o big_writes
 1264 user    20      409772 172380 130272 S         2,9   3:44.87 /opt/vivaldi/vivaldi-bin --type=gpu-process --field-trial-handle=3915765391718663846,6007434879633374880,131072 --+
 1269 user    20      326568  84068  57472 S         1,4   0:06.37 /opt/vivaldi/vivaldi-bin --type=utility --field-trial-handle=3915765391718663846,6007434879633374880,131072 --lang+
 1337 user    20      610792 158560  91972 S         2,7   1:54.66 /opt/vivaldi/vivaldi-bin --type=renderer --field-trial-handle=3915765391718663846,6007434879633374880,131072 --lan+
 1344 user    20       10,5g 112928  65828 S         1,9   0:08.60 /opt/vivaldi/vivaldi-bin --type=renderer --field-trial-handle=3915765391718663846,6007434879633374880,131072 --lan+
 1350 user    20      632328 204496 114712 S         3,4   2:30.84 /opt/vivaldi/vivaldi-bin --type=renderer --field-trial-handle=3915765391718663846,6007434879633374880,131072 --lan+
 1442 user    20      515452  98496  72976 S         1,6   0:00.88 /opt/vivaldi/vivaldi-bin --type=renderer --field-trial-handle=3915765391718663846,6007434879633374880,131072 --lan+
 1540 user    20      110012  17104  13908 S         0,3   0:00.06 file.so [kdeinit5] file local:/run/user/1000/klauncherHxprTy.1.slave-socket local:/run/user/1000/kded5DUfMlI.1.sla+
 1566 user    20      585740  88840  71396 S         1,5   0:06.39 /usr/bin/dolphin
 1593 user    20      404696  59232  49072 S         1,0   0:00.99 /usr/lib/kf5/kiod5
 1802 user    20      533972 110320  74508 S         1,8   0:03.22 /opt/vivaldi/vivaldi-bin --type=renderer --field-trial-handle=3915765391718663846,6007434879633374880,131072 --lan+
 1867 user    20      528800 111092  76412 S         1,9   0:02.29 /opt/vivaldi/vivaldi-bin --type=renderer --field-trial-handle=3915765391718663846,6007434879633374880,131072 --lan+
 1881 user    20       11300   6764   4332 S         0,1   0:00.40 /usr/bin/zsh
 2678 user    20       10848   6456   4424 S         0,1   0:00.14 /usr/bin/zsh
 2778 user    20       10484   4732   2688 S         0,1   0:00.18 man top
 2787 user    20       10484   2044        S         0,0           man top
 2788 user    20        7068   3304   2840 S         0,1   0:00.05 less
 3851 user    20      552376 121984  76552 S         2,0   0:03.00 /opt/vivaldi/vivaldi-bin --type=renderer --field-trial-handle=3915765391718663846,6007434879633374880,131072 --lan+
 3895 user    20      528348 106108  78408 S         1,8   0:04.08 /opt/vivaldi/vivaldi-bin --type=renderer --field-trial-handle=3915765391718663846,6007434879633374880,131072 --lan+
 3908 user    20      570672 134360  83152 S         2,2   0:25.37 /opt/vivaldi/vivaldi-bin --type=renderer --field-trial-handle=3915765391718663846,6007434879633374880,131072 --lan+
 4264 user    20      463156  45880  33804 S         0,8   0:00.05 /opt/vivaldi/vivaldi-bin --type=renderer --field-trial-handle=3915765391718663846,6007434879633374880,131072 --lan+
@csbc92
Copy link

csbc92 commented Aug 20, 2019

I've got the same issue here after cloning the most recent update (commit 717e945).

Output:

Creating wallpaper...
Traceback (most recent call last):
  File "generateWallpaper.py", line 50, in <module>
    ).generate_from_frequencies(resourceDict)
  File "/home/ccl/.local/lib/python3.7/site-packages/wordcloud/wordcloud.py", line 383, in generate_from_frequencies
    "got %d." % len(frequencies))
ValueError: We need at least 1 word to plot a word cloud, got 0.
Setting wallpaper...
/usr/bin/gsettings
Setup successfully completed

@anirudhajith
Copy link
Owner

@zaphbbrox

The %CPU stat is missing for all of your processes (except top).

That's what's causing the problem. I'll work on a fix soon.

@zaphbbrox
Copy link
Author

zaphbbrox commented Aug 20, 2019

@anirudhajith I found a workaround to successfully generate a wallpaper:
In /etc/topdefaultrc I changed Zero_suppress=1 to Zero_suppress=0 and now at least my top.out has a similiar output like yours.
With this I can generate a wallpaper, but I got the feeling some of the stuff is missing. For example: I'm playing a video in VLC and in top.out I find:

7771 user    20   0 2029900 142344  84348 S  31,2   2,4   0:13.99 /usr/bin/vlc --started-from-file smb://share@NAS/Videos/Misc/samplevid.mkv

But in the wallpaper I can't see VLC.

@Hachiverol
Copy link

oh boy still not fixed. i wonder why the output of top differs so much

@dsluo
Copy link
Contributor

dsluo commented Aug 31, 2019

@Hachiverol top isn't exactly supposed to be machine readable. There's better APIs for that. Currently planning on moving to psutil for better compatibility. See #20.

@dsluo dsluo added bug Something isn't working compatibility Issue is related to compatibility. labels Aug 31, 2019
@Hachiverol
Copy link

@dsluo How about glances. it's python based and supports json and csv.

@dsluo
Copy link
Contributor

dsluo commented Sep 2, 2019

@Hachiverol glances depends on psutil.

In any case, it's pretty heavyweight for what we're trying to do.

@Hachiverol
Copy link

About the mac output difference. I don't own a mac. Can someone provide the output of psutil in mac, for curiosity's sake.

@anirudhajith
Copy link
Owner

@Hachiverol @dsluo
I've attempted a port to psutil on a new branch: d753165
This should work on all platforms since we're not relying on the precise format of the output of top.

@zaphbbrox
Copy link
Author

@anirudhajith
I just tested the psutil branch and it works fine with Manjaro KDE. So from my side the issue can be closed.

@anirudhajith
Copy link
Owner

@dsluo Shall we merge psutil into master? Do you want to make any changes before that?

@dsluo
Copy link
Contributor

dsluo commented Sep 11, 2019

@anirudhajith The last time I looked into this, I remember reading that psutil's cpu_percent (and maybe memory_percent as well; I don't recall) only gives back a non-zero percentage after the first time it's retrieved. The code as it is now may not be accurately measuring resource usage due to this, as we only ever get CPU usage once per process. Simply retrieving all the stats that you can and then waiting 0.1 seconds or so should fix it.

I was working on making some changes addressing this and a few places where I think that code quality could be improved, but I've been busy preparing for and participating in interviews.

@anirudhajith
Copy link
Owner

@dsluo Haven't you already fixed this? I think you've put in a delay of 0.2 seconds?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compatibility Issue is related to compatibility.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants