0002303: 404 from auto-generated Help > Automatic python modules documentation
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <QBuffer>
|
||||
# include <QImageWriter>
|
||||
# include <QMessageBox>
|
||||
# include <QTcpSocket>
|
||||
#endif
|
||||
@@ -33,6 +34,8 @@
|
||||
#include <zipios++/zipfile.h>
|
||||
#include <Base/Interpreter.h>
|
||||
#include <Base/Stream.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <App/Application.h>
|
||||
|
||||
#include "MainWindow.h"
|
||||
@@ -83,10 +86,24 @@ QByteArray PythonOnlineHelp::loadResource(const QString& filename) const
|
||||
QByteArray res;
|
||||
|
||||
if (fn == QLatin1String("favicon.ico")) {
|
||||
// Return an resource icon in ico format
|
||||
res.reserve(navicon_data_len);
|
||||
for (int i=0; i<(int)navicon_data_len;i++) {
|
||||
res[i] = navicon_data[i];
|
||||
// Return a resource icon in ico format
|
||||
QBuffer buffer;
|
||||
buffer.open(QBuffer::WriteOnly);
|
||||
QImageWriter writer;
|
||||
writer.setDevice(&buffer);
|
||||
writer.setFormat("ICO");
|
||||
if (writer.canWrite()) {
|
||||
QPixmap px = qApp->windowIcon().pixmap(24,24);
|
||||
writer.write(px.toImage());
|
||||
buffer.close();
|
||||
res = buffer.data();
|
||||
}
|
||||
else {
|
||||
// fallback
|
||||
res.reserve(navicon_data_len);
|
||||
for (int i=0; i<(int)navicon_data_len;i++) {
|
||||
res[i] = navicon_data[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (filename == QLatin1String("/")) {
|
||||
@@ -163,8 +180,8 @@ QByteArray PythonOnlineHelp::loadResource(const QString& filename) const
|
||||
}
|
||||
else {
|
||||
// load the error page
|
||||
PyErr_Clear();
|
||||
res = fileNotFound();
|
||||
Base::PyException e;
|
||||
res = loadFailed(QString::fromUtf8(e.what()));
|
||||
}
|
||||
|
||||
Py_DECREF(dict);
|
||||
@@ -198,9 +215,10 @@ QByteArray PythonOnlineHelp::loadResource(const QString& filename) const
|
||||
else {
|
||||
// get information about the error
|
||||
Base::PyException e;
|
||||
Base::Console().Warning("PythonOnlineHelp::loadResource: %s\n", e.what());
|
||||
//Base::Console().Error("loadResource: %s\n", e.what());
|
||||
// load the error page
|
||||
res = fileNotFound();
|
||||
//res = fileNotFound();
|
||||
res = loadFailed(QString::fromUtf8(e.what()));
|
||||
}
|
||||
|
||||
Py_DECREF(dict);
|
||||
@@ -241,6 +259,36 @@ QByteArray PythonOnlineHelp::fileNotFound() const
|
||||
return res;
|
||||
}
|
||||
|
||||
QByteArray PythonOnlineHelp::loadFailed(const QString& error) const
|
||||
{
|
||||
QString contentType = QString::fromLatin1(
|
||||
"text/html\r\n"
|
||||
"\r\n"
|
||||
"<html><head><title>Error</title></head>"
|
||||
"<body bgcolor=\"#f0f0f8\">"
|
||||
"<table width=\"100%\" cellspacing=0 cellpadding=2 border=0 summary=\"heading\">"
|
||||
"<tr bgcolor=\"#7799ee\">"
|
||||
"<td valign=bottom> <br>"
|
||||
"<font color=\"#ffffff\" face=\"helvetica, arial\"> <br><big><big><strong>FreeCAD Documentation</strong></big></big></font></td>"
|
||||
"<td align=right valign=bottom>"
|
||||
"<font color=\"#ffffff\" face=\"helvetica, arial\"> </font></td></tr></table>"
|
||||
"<p><p>"
|
||||
"<h1>%1</h1>"
|
||||
"</body>"
|
||||
"</html>"
|
||||
"\r\n"
|
||||
).arg(error);
|
||||
|
||||
QString header = QString::fromLatin1("content-type: %1\r\n").arg(contentType);
|
||||
|
||||
QString http(QLatin1String("HTTP/1.1 %1 %2\r\n%3\r\n"));
|
||||
QString httpResponseHeader = http.arg(404).arg(QLatin1String("File not found")).arg(header);
|
||||
|
||||
QByteArray res;
|
||||
res.append(httpResponseHeader);
|
||||
return res;
|
||||
}
|
||||
|
||||
HttpServer::HttpServer(QObject* parent)
|
||||
: QTcpServer(parent), disabled(false)
|
||||
{
|
||||
|
||||
@@ -49,6 +49,7 @@ public:
|
||||
|
||||
QByteArray loadResource(const QString& filename) const;
|
||||
QByteArray fileNotFound() const;
|
||||
QByteArray loadFailed(const QString& error) const;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
from Robot import *
|
||||
from Part import *
|
||||
from FreeCAD import *
|
||||
import FreeCAD as App
|
||||
import tempfile
|
||||
|
||||
# === Basic robot stuff ===
|
||||
# create the robot. If you not specify a other kinematic it becomes a Puma 560
|
||||
@@ -66,10 +68,10 @@ App.activeDocument().Robot.Axis2 = -90
|
||||
App.activeDocument().Robot.Axis3 = 90
|
||||
|
||||
# retrive the Tcp position
|
||||
pos = FreeCAD.getDocument("Unnamed").getObject("Robot").Tcp
|
||||
pos = App.getDocument("Unnamed").getObject("Robot").Tcp
|
||||
# move the robot
|
||||
pos.move(App.Vector(-10,0,0))
|
||||
FreeCAD.getDocument("Unnamed").getObject("Robot").Tcp = pos
|
||||
App.getDocument("Unnamed").getObject("Robot").Tcp = pos
|
||||
|
||||
# create an empty Trajectory object in the active document
|
||||
App.activeDocument().addObject("Robot::TrajectoryObject","Trajectory")
|
||||
@@ -97,7 +99,7 @@ print(App.activeDocument().Trajectory.Trajectory)
|
||||
# python module. Here is in detail the Kuka Postprocessor descriped
|
||||
from KukaExporter import ExportCompactSub
|
||||
|
||||
ExportCompactSub(App.activeDocument().Robot,App.activeDocument().Trajectory,'D:/Temp/TestOut.src')
|
||||
ExportCompactSub(App.activeDocument().Robot,App.activeDocument().Trajectory,tempfile.gettempdir()+'/TestOut.src')
|
||||
|
||||
# and thats kind of how its done:
|
||||
for w in App.activeDocument().Trajectory.Trajectory.Waypoints:
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# Examples to generate trajectories out of shapes
|
||||
import FreeCADGui as Gui
|
||||
|
||||
# geting selected edges from the selection and sort them
|
||||
count = 0
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
from Sketcher import *
|
||||
from Part import *
|
||||
from FreeCAD import *
|
||||
import FreeCAD as App
|
||||
|
||||
# set some constances for the constraints
|
||||
StartPoint = 1
|
||||
|
||||
Reference in New Issue
Block a user