I program my experiments on a Macbook Pro with OSX 10.9.5, graphic card Intel HD Graphics 4000 1024 MB, with VLC Version 2.0.10 Twoflower (Intel 32bit). I used to present videos (avi and mp4 files, 60 frames per second) successfully with moviestim up to version 1.80. After upgrading to version 1.81 by installing the standalone version I tried to use moviestim2, adapting the code in Moviestim2.py. When I run the code below:
from psychopy import visual, core
import time, os, pylab
os.chdir('/Users/till/work/edv/psychopy/test/')
win = visual.Window([1440, 900])
win.setRecordFrameIntervals(True)
mov = visual.MovieStim2(win, 'jwpIntro.mov',
size=[800,800],
pos=[0, 100],
flipVert=False,
flipHoriz=False,
loop=False)
shouldflip = mov.play()
while mov.status != visual.FINISHED:
if shouldflip:
win.flip()
else:
time.sleep(0.001)
shouldflip = mov.draw()
intervalsMS = pylab.array(win.frameIntervals[1:])*1000
m=pylab.mean(intervalsMS)
nTotal=len(intervalsMS)
nDropped=sum(intervalsMS>(1.5*m))
print "nTotal", nTotal
print "nDropped", nDropped
core.quit()
the video is shown in full length, the output is
nTotal 142
nDropped 2
(Warnings deleted). When I run the code with one of my videos (file format mov, size adjusted to 800x800), generated with ffmpeg in format H.264 from 852 png files with 60 frames per second to show moving objects for a tracking task (no audio data), the window closes immediately after probably showing the first frame. The output is
nTotal 0
nDropped 0
/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/numpy/core/_methods.py:55: RuntimeWarning: Mean of empty slice.
warnings.warn("Mean of empty slice.", RuntimeWarning)
/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/numpy/core/_methods.py:67: RuntimeWarning: invalid value encountered in double_scalars
ret = ret.dtype.type(ret / rcount)
(Other warnings deleted) Tests with file formats avi and mp4 generated nTotals of 1 to 2 and accordingly no Runtime Warnings and the same result.
Any help would be appreciated, because up to now I was not able to return to PsychoPy 1.80 using moviestim as before with avbin 10 (window freezes, but PsychoPy does not crash) as a workaround.
Best,
Till
The issue likely has to do with your videos not having any audio track. Try setting the 'noAudio' kwarg to True when you create the MovieStim2.
visual.MovieStim2(win, 'jwpIntro.mov',
size=[800,800],
pos=[0, 100],
noAudio=True,
flipVert=False,
flipHoriz=False,
loop=False)
MovieStim2 should really be able to auto detect when there is no audio stream at all; so that should be changed when there is time. ;)
If the above does not work, can you post a link to one of your sample videos so I can download and debug?
Update: I tested my suggested workaround, only to discover it uncovered some other issues. (Arrrg..) These issues are now fixed, however this means that for this suggestion to work, you will need to update your psychopy package source from the psychopy github master stream as of October 23rd, 2014, or use an official package update if one is available that was released after this date.
Related
I am trying to run a full system simulation of gem5, but I found that the full system file of X86 on the official website can no longer be downloaded, can someone help me?
thanks
I need a compressed package of x86 full system files“x86-system.tar.bz2”“config-x86.tar.bz2”
Here is a complete tutorial on how to run FS in gem5. Start by downloading your OS image:
https://www.gem5.org/documentation/gem5art/main/disks
from gem5.utils.requires import requires
from gem5.components.boards.x86_board import X86Board
from gem5.components.memory.single_channel import SingleChannelDDR3_1600
from gem5.components.cachehierarchies.ruby.mesi_two_level_cache_hierarchy import (
MESITwoLevelCacheHierarchy,
)
from gem5.components.processors.simple_switchable_processor import (
SimpleSwitchableProcessor,
)
from gem5.coherence_protocol import CoherenceProtocol
from gem5.isas import ISA
from gem5.components.processors.cpu_types import CPUTypes
from gem5.resources.resource import Resource
from gem5.simulate.simulator import Simulator
from gem5.simulate.exit_event import ExitEvent
This runs a check to ensure the gem5 binary is compiled to X86 and supports
requires(
isa_required=ISA.X86, coherence_protocol_required=CoherenceProtocol.MESI_TWO_LEVEL
)
Here we setup a MESI Two Level Cache Hierarchy.
cache_hierarchy = MESITwoLevelCacheHierarchy(
l1d_size="32KiB",
l1d_assoc=8,
l1i_size="32KiB",
l1i_assoc=8,
l2_size="256KiB",
l2_assoc=16,
num_l2_banks=1,
)
Setup the system memory.
Note, by default DDR3_1600 defaults to a size of 8GiB. However, a current
limitation with the X86 board is it can only accept memory systems up to 3GiB.
As such, we must fix the size.
memory = SingleChannelDDR3_1600("2GiB")
Here we setup the processor. This is a special switchable processor in which a starting core type and a switch core type must be specified. Once a configuration is instantiated a user may call processor.switch() to switch from the starting core types to the switch core types. In this simulation we start with TIMING cores to simulate the OS boot, then switch to the O3 cores for the command we wish to run after boot.
processor = SimpleSwitchableProcessor(
starting_core_type=CPUTypes.TIMING, switch_core_type=CPUTypes.O3, num_cores=2
)
Here we setup the board. The X86Board allows for Full-System X86 simulations.
board = X86Board(
clk_freq="3GHz", processor=processor, memory=memory, cache_hierarchy=cache_hierarchy
)
This is the command to run after the system has booted. The first m5 exit will stop the simulation so we can switch the CPU cores from TIMING to O3d and continue the simulation to run the echo command, sleep for a second, then, again, call m5 exit to terminate the simulation. After simulation has ended you may inspect m5out/system.pc.com_1.device to see the echo output.
command = (
"m5 exit;" + "echo 'This is running on O3 CPU cores.';" + "sleep 1;" + "m5 exit;"
)
Here we set the Full System workload. The set_workload function for the X86Board takes a kernel, a disk image, and, optionally, a the contents of the "readfile". In the case of the "x86-ubuntu-18.04-img", a file to be executed as a script after booting the system.
board.set_kernel_disk_workload(
kernel=Resource("x86-linux-kernel-5.4.49"),
disk_image=Resource("x86-ubuntu-18.04-img"),
readfile_contents=command,
)
Here we want override the default behavior for the first m5 exit exit event. Instead of exiting the simulator, we just want to switch the processor. The 2nd 'm5 exit' after will revert to using default behavior where the simulator run will exit.
simulator = Simulator(
board=board,
on_exit_event={
ExitEvent.EXIT: (func() for func in [processor.switch])
},
)
simulator.run()
This Python code shows how to call some process in Windows 10 and to send to it string commands, to read its string responses through stdin, stdout pipes of the process:
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from subprocess import *
>>> p = Popen("c:/python38/python.exe", stdin=PIPE, stdout=PIPE)
>>> p.stdin.write(b"print(1+9)\n")
11
>>> p.communicate()
(b'10\r\n', None)
>>>
As you can see the python.exe process returned 10 as an answer to print(1+9). Now I want to do the same in Pharo (or Squeak): in Windows 10 OS - I suppose something similar, i.e. short, simple, understandable, really working.
I installed OSProcess, ProcessWrapper (they were missing in Pharo, also its strange that I got warning that they are not marked for Pharo 8.0 and were not checked to work in Pharo 8.0, but OK), and I tried ProcessWrapper, PipeableOSProcess (copy-pasted different snippets from the Web), etc - with zero success! The results were:
nothing happens, python.exe was not started
VM errors console was opened (white console in the bottom of the Pharo, which is controlled with F2 menu)
different exceptions
etc
Would somebody show me simple working example how to start a process and to to send it commands, read answers, then send again, and so on in some loop - I plan to have such communication in a detached thread and to use it as some service, because Pharo, Smalltalk in general is missing most bindings, so then I will use subprocess communication like in "good" old days...
I know how to call a command and to get its output:
out := LibC resultOfCommand: 'dir ', aDir.
but I am talking about another scenario: a communication with a running process interactively (for example, with SSH or similar like in the example above - python.exe).
PS. Maybe it's possible to do it with LibC #pipe:mode even?
Let me start with that the PipeableOsProcess is probably broken on Windows. I have tried it and it just opened a command line and nothing else (it does not freeze my Pharo 8). The whole OSProcess does not work correctly in my eyes.
So I took a shot at LibC which is supposed to not work with Windows.
I’m a module defining access to standard LibC. I’m available under Linux and OSX, but not under Windows for obvious reasons :)
Next is to say that Python's Windows support is probably much better than Pharo's.
The solution, which is more like a workaround using files, is to use LibC and #runCommand: (I tried to come up with a similar example as you had shown above):
| count command result outputFile errorFile |
count := 9+1. "The counting"
command := 'echo ', count asString. "command run at the command line"
outputFile := 'output'. "a file into which the output is redirected"
errorFile := 'error'. "a file where the error output is redirected "
result := LibC runCommand: command, "run the command "
' >', outputFile, "redirect the output to output file"
' 2>', errorFile.
"reading back the value from output file"
outputFile asFileReference contents lines.
"reading back the value from the error file - which is empty in this case"
errorFile asFileReference contents lines.
I Have This Algorithm Below:
from bs4 import BeautifulSoup
import requests
import time
soup=BeautifulSoup(html,'html.parser')
for link in soup.select('div.sg-actions-list__hole > a[href*="/tarefa"]'):
ref=link.get('href')
rt = ('https://brainly.com.br'+str(ref))
p.append(rt)
print(p)
for url in p:
r = requests.get(url).text
time.sleep(10)
print(r)
Which basically imprints the source code of the page.
My Problem Is Not About the Algorithm, but About IDLE because when you print the page source code it is too big that some parts of the HTML end up disappearing, my question is if there is any solution to this.
I cannot guess what 'redenected' is supposed to mean. In any case, please specify your OS and OS version, and how many characters and lines your are trying to print ('len(p), count( Also, try to reproduce the problem without involving beautiful soup, a 3rd party module, by generating the text in your program.
For instance, on Windows 10 with 3.9.0a1, I can print a 100000 line text.
>>> def f(n):
nl = '\n'
s=('a'*60 + nl)*n
print(f"s has {len(s)} chars, {s.count(nl)} lines")
print(s)
>>> f(100000)
s has 6100000 chars, 100000 lines
[Squeezed text (100000 lines).] # Reverse text box after about 1/2 minute.
Squeezing large output was introduced late 2018. It protects against the freeze effect of long lines. As should be explained in the IDLE doc, squeezed text can copied to the clipboard, viewed in a separate window, or expanded in the shell.
Is there a Mono profiler mode similar to Java -Xloggc?
I would like to see a human readable GC report while my application is running. Currently Mono can be run with --profile=log option but the output is in binary format and every time I need to run mprof-report to read it. The output file also contains a lot of info which is not interesting for me.
I tried to reduce the file size by specifying heapshot=14400000ms to collect statistics every few hours but it didn't help a lot. In a week I had few gigabytes log.
I also tried to use "sample" profiler but the overhead was too much.
You can use Mono's trace filters for this. Just set the MONO_LOG_MASK to gc and lower the MONO_LOG_LEVEL. Then run your app normally and you will get the human-readable GC statistics while your app is running:
$ export MONO_LOG_MASK=gc
$ export MONO_LOG_LEVEL=debug
$ mono ... # run your application normally ..
...
# notice the human readable GC output
mono: GC_MAJOR: (LOS overflow) pause 26.00ms, total 26.06ms, bridge 0.00ms major 31472K/0K los 1575K/0K
Mono: GC_MINOR: (Nursery full) pause 2.30ms, total 2.35ms, bridge 0.00ms promoted 31456K major 31456K los 5135K
Mono: GC_MINOR: (Nursery full) pause 2.43ms, total 2.45ms, bridge 0.00ms promoted 31456K major 31456K los 8097K
Mono: GC_MINOR: (Nursery full) pause 1.80ms, total 1.82ms, bridge 0.00ms promoted 31472K major 31472K los 11425K
I tried carl function
http://www.rebol.com/article/0281.html
with 155 Mo it works.
Then I tested with 7 Go it fails without saying the limit.
Why is there a limit I can't see anything in code that puts a limit.
There's no error message
>> copy-file to-rebol-file "D:\#mirror_ftp\cpmove.tar" to-rebol-file "D:\#mirror_ftp\testcopy.tar"
0:00
== none
>>
REBOL uses 32-bit signed integers, so it can't read files bigger than 2147483647 bytes (2^31-1) which is roughly 2GB. REBOL3 uses 64-bit integers, so won't have such limitation.