
Recherche avancée
Médias (1)
-
La conservation du net art au musée. Les stratégies à l’œuvre
26 mai 2011
Mis à jour : Juillet 2013
Langue : français
Type : Texte
Autres articles (59)
-
MediaSPIP v0.2
21 juin 2013, parMediaSPIP 0.2 est la première version de MediaSPIP stable.
Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...) -
Configuration spécifique pour PHP5
4 février 2011, parPHP5 est obligatoire, vous pouvez l’installer en suivant ce tutoriel spécifique.
Il est recommandé dans un premier temps de désactiver le safe_mode, cependant, s’il est correctement configuré et que les binaires nécessaires sont accessibles, MediaSPIP devrait fonctionner correctement avec le safe_mode activé.
Modules spécifiques
Il est nécessaire d’installer certains modules PHP spécifiques, via le gestionnaire de paquet de votre distribution ou manuellement : php5-mysql pour la connectivité avec la (...) -
Les autorisations surchargées par les plugins
27 avril 2010, parMediaspip core
autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs
Sur d’autres sites (9196)
-
A Guide to Bank Customer Segmentation
18 juillet 2024, par Erin -
C# .net mvc Process return encoding progress (FFMpeg) to client initiated with ajax
19 décembre 2014, par user1585895I am using FFMpeg to encode wav to mp3s, and on completion download the final .zip to the client.
All works great, and I can Debug.WriteLine the progress of the encoding, but I would like to return _percentage back to the client to do some UI updates based on the value of _percentage and if all encoding is done, Im not sure how to approach this.
My thinking is as follows :
- ajax post to CreateAndDownloadAlbum(List trackIds, int productId)
- loop through List and create a new Process, run
— parse StdError to get encoding percentage in myProcess_ErrorData(object source, DataReceivedEventArgs e)
— send _percentage value at timed intervals back to CreateAndDownloadAlbum
— update UI based on value of _percentage, when all is complete break and call public ActionResult SendFileDownload()
Any input would be great.
Thanks !
front end AJAX call to post list of file Ids to download
var data = $('#downloadAlbum').serialize();
$.ajax({
url: "/Admin/CreateAndDownloadAlbum",
method: "POST",
data: data,
dataType: 'json',
success: function(result) {
// wait here for _percentage
// if not 100, call again to get new _percentage value
// if 100, update UI, move to next file being encoded
// if all encoding is complete, call SendFileDownload() in controller
}
});then the controller code
[HttpPost]
public void CreateAndDownloadAlbum(List<trackstodownload> trackIds, int productId)
{
_numTracksToDownload = trackIds.Count;
var product = _productRepository.GetProductById(productId);
var artist = _artistRepository.GetArtistById(product.ArtistId);
var folderGuid = Guid.NewGuid();
_zipFolder = string.Concat(artist.ArtistName.ToUpper().Replace(" ", "_"), "[", product.ProductName.ToUpper().Replace(" ", "_"), "].zip");
_mp3FolderPath = Server.MapPath("/Files/" + productId + "/" + folderGuid);
_zipDownloadPath = Server.MapPath("/Delivery/" + _zipFolder);
if (!Directory.Exists(Server.MapPath("/Files/" + productId + "/" + folderGuid)))
{
Directory.CreateDirectory(Server.MapPath("/Files/" + productId + "/" + folderGuid));
}
foreach (var z in trackIds)
{
var track = _trackRepository.GetTrackById(z.TrackId);
var process = new Process();
var startInfo = new ProcessStartInfo
{
WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden,
FileName = "F:\\Development\\ffmpeg\\ffmpeg.exe",
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false
};
var startFile = Path.Combine("F:\\Development","Files", track.ProductId.ToString(), track.TrackFileName);
var endFile = Path.Combine("F:\\Development", "Files", track.ProductId.ToString(), folderGuid.ToString(), track.TrackFileName.Replace(".wav", ".mp3"));
startInfo.Arguments = "-i " + startFile + " -b:a 320k " + endFile + " -stats";
process.StartInfo = startInfo;
process.EnableRaisingEvents = true;
process.Exited += myProcess_exited;
process.OutputDataReceived += myProcess_OutputData;
process.ErrorDataReceived += myProcess_ErrorData;
try
{
process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
if (process.HasExited == false)
{
process.WaitForExit();
}
}
catch (Exception)
{
throw;
}
}
SendFileDownload();
}
public ActionResult SendFileDownload()
{
// zip and move to delivery folder
using (var zip = new ZipFile())
{
zip.AddDirectory(_mp3FolderPath, _zipFolder);
zip.Save(_zipDownloadPath);
}
// delete items in temp guid folder
var downloadedMessageInfo = new DirectoryInfo(_mp3FolderPath);
foreach (var f in downloadedMessageInfo.GetFiles())
{
f.Delete();
}
// delete temp folder
Directory.Delete(_mp3FolderPath);
// download file
string file = _zipDownloadPath;
return File(file, "application/force-download", Path.GetFileName(file));
}
public void myProcess_exited(Object source, EventArgs e)
{
Debug.WriteLine("myProcess_exited ===================================");
_duration = new TimeSpan(0, 0, 0);
_frameTime = new TimeSpan(0, 0, 0);
_percentage = 0;
_numEncodedTracks++; // using this to tell me if all tracks have been encoded
}
public void myProcess_OutputData(object source, DataReceivedEventArgs e)
{
}
public void myProcess_ErrorData(object source, DataReceivedEventArgs e)
{
string strMessage = e.Data;
if (!string.IsNullOrEmpty(strMessage) && (strMessage.Contains("Duration: ") || strMessage.Contains("size=")))
{
if (_duration != null)
{
if (strMessage.Contains("Duration: "))
{
_strDuration = strMessage.Substring(strMessage.IndexOf("Duration: ") + ("Duration: ").Length,
("00:00:00.00").Length);
char[] d_delHrMn = new char[] { ':' };
string[] d_tempHrMn = _strDuration.Split(d_delHrMn, StringSplitOptions.RemoveEmptyEntries);
char[] d_delSec = new char[] { '.' };
string[] d_tempSec = d_tempHrMn[2].Split(d_delSec, StringSplitOptions.RemoveEmptyEntries);
var d_hour = d_tempHrMn[0] == "0" ? 0 : Convert.ToInt32(d_tempHrMn[0]);
var d_min = d_tempHrMn[1] == "0" ? 0 : Convert.ToInt32(d_tempHrMn[1]);
var d_sec = d_tempSec[0] == "0" ? 0 : Convert.ToInt32(d_tempSec[0]);
_duration = new TimeSpan(d_hour, d_min, d_sec);
}
}
if (strMessage.Contains("size="))
{
_strFrameTime = strMessage.Substring(strMessage.IndexOf("time=") + ("time=").Length,
("00:00:00.00").Length);
char[] f_delHrMn = new char[] { ':' };
string[] f_tempHrMn = _strFrameTime.Split(f_delHrMn, StringSplitOptions.RemoveEmptyEntries);
char[] f_delSec = new char[] { '.' };
string[] f_tempSec = f_tempHrMn[2].Split(f_delSec, StringSplitOptions.RemoveEmptyEntries);
var f_hour = f_tempHrMn[0] == "0" ? 0 : Convert.ToInt32(f_tempHrMn[0]);
var f_min = f_tempHrMn[1] == "0" ? 0 : Convert.ToInt32(f_tempHrMn[1]);
var f_sec = f_tempSec[0] == "0" ? 0 : Convert.ToInt32(f_tempSec[0]);
_frameTime = new TimeSpan(f_hour, f_min, f_sec);
}
if (_strDuration != "00:00:00.00" && _strFrameTime != "00:00:00.00" && _percentage < 100)
{
_percentage = _frameTime.TotalMilliseconds / _duration.TotalMilliseconds * 100;
Debug.WriteLine(_percentage + " || " + _frameTime + " " + _duration);
}
}
}
</trackstodownload> -
How to write UI tests for your plugin – Introducing the Piwik Platform
18 février 2015, par Thomas Steur — DevelopmentThis is the next post of our blog series where we introduce the capabilities of the Piwik platform (our previous post was How to write unit tests for your plugin). This time you’ll learn how to write UI tests in Piwik. For this tutorial you will need to have basic knowledge of JavaScript and the Piwik platform.
What is a UI test ?
Some might know a UI test under the term ‘CSS test’ or ‘screenshot test’. When we speak of UI tests we mean automated tests that capture a screenshot of a URL and then compare the result with an expected image. If the images are not exactly the same the test will fail. For more information read our blog post about UI Testing.
What is a UI test good for ?
We use them to test our PHP Controllers, Twig templates, CSS, and indirectly test our JavaScript. We do usually not write Unit or Integration tests for our controllers. For example we use UI tests to ensure that the installation, the login and the update process works as expected. We also have tests for most pages, reports, settings, etc. This increases the quality of our product and saves us a lot of time as it is easy to write and maintain such tests. All UI tests are executed on Travis after each commit and compared with our expected screenshots.
Getting started
In this post, we assume that you have already installed Piwik 2.11.0 or later via git, set up your development environment and created a plugin. If not, visit the Piwik Developer Zone where you’ll find the tutorial Setting up Piwik and other Guides that help you to develop a plugin.
Next you need to install the needed packages to execute UI tests.
Let’s create a UI test
We start by using the Piwik Console to create a new UI test :
./console generate:test --testtype ui
The command will ask you to enter the name of the plugin the created test should belong to. I will use the plugin name “Widgetize”. Next it will ask you for the name of the test. Here you usually enter the name of the page or report you want to test. I will use the name “WidgetizePage” in this example. There should now be a file
plugins/Widgetize/tests/UI/WidgetizePage_spec.js
which contains already an example to get you started easily :describe("WidgetizePage", function () {
var generalParams = 'idSite=1&period=day&date=2010-01-03';
it('should load a simple page by its module and action', function (done) {
var screenshotName = 'simplePage';
// will save image in "processed-ui-screenshots/WidgetizePageTest_simplePage.png"
expect.screenshot(screenshotName).to.be.capture(function (page) {
var urlToTest = "?" + generalParams + "&module=Widgetize&action=index";
page.load(urlToTest);
}, done);
});
});What is happening here ?
This example declares a new set of specs by calling the method
describe(name, callback)
and within that a new spec by calling the methodit(description, func)
. Within the spec we load a URL and once loaded capture a screenshot of the whole page. The captured screenshot will be saved under the definedscreenshotName
. You might have noticed we write our UI tests in BDD style.Capturing only a part of the page
It is good practice to not always capture the full page. For example many pages contain a menu and if you change that menu, all your screenshot tests would fail. To avoid this you would instead have a separate test for your menu. To capture only a part of the page simply specify a jQuery selector and call the method
captureSelector
instead ofcapture
:var contentSelector = '#selector1, .selector2 .selector3';
// Only the content of both selectors will be in visible in the captured screenshot
expect.screenshot('page_partial').to.be.captureSelector(contentSelector, function (page) {
page.load(urlToTest);
}, done);Hiding content
There is a known issue with sparklines that can fail tests randomly. Also version numbers or a date that changes from time to time can fail tests without actually having an error. To avoid this you can prevent elements from being visible in the captured screenshot via CSS as we add a CSS class called
uiTest
to theHTML
element while tests are running..uiTest .version { visibility:hidden }
Running a test
To run the previously generated tests we will use the command
tests:run-ui
:./console tests:run-ui WidgetizePage
After running the tests for the first time you will notice a new folder
plugins/PLUGINNAME/tests/UI/processed-ui-screenshots
in your plugin. If everything worked, there will be an image for every captured screenshot. If you’re happy with the result it is time to copy the file over to theexpected-ui-screenshots
folder, otherwise you have to adjust your test until you get the result you want. From now on, the newly captured screenshots will be compared with the expected images whenever you execute the tests.Fixing a test
At some point your UI test will fail, for example due to expected CSS changes. To fix a test all you have to do is to copy the captured screenshot from the folder
processed-ui-screenshots
to the folderexpected-ui-screenshots
.Executing the UI tests on Travis
In case you have not generated a
.travis.yml
file for your plugin yet you can do this by executing the following command :./console generate:travis-yml --plugin PLUGINNAME
Next you have to activate Travis for your repository.
Advanced features
Isn’t it easy to create a UI test ? We never even created a file ! Of course you can accomplish even more if you want. For example you can specify a fixture to be inserted before running the tests which is useful when your plugin requires custom data. You can also control the browser as it was a human by clicking, moving the mouse, typing text, etc. If you want to discover more features have a look at our existing test cases.
If you have any feedback regarding our APIs or our guides in the Developer Zone feel free to send it to us.