Beispiel #1
0
//-------------------------------------------------------------------------------------
void Proxy::giveClientTo(Proxy* proxy)
{
	if(clientMailbox_ == NULL || clientMailbox_->getChannel() == NULL)
	{
		char err[255];																				
		kbe_snprintf(err, 255, "Proxy[%s]::giveClientTo: no has client.", getScriptName());			
		PyErr_SetString(PyExc_TypeError, err);														
		PyErr_PrintEx(0);	
		onGiveClientToFailure();
		return;
	}

	Mercury::Channel* lpChannel = clientMailbox_->getChannel();

	if(proxy)
	{
		EntityMailbox* mb = proxy->getClientMailbox();
		if(mb != NULL)
		{
			ERROR_MSG(boost::format("Proxy::giveClientTo: %1%[%2%] give client to %3%[%4%], %5% have clientMailbox.\n") % 
					getScriptName() %
					getID() %
					proxy->getScriptName() % 
					proxy->getID() %
					proxy->getScriptName());

			onGiveClientToFailure();
			return;
		}

		if(getCellMailbox())
		{
			// 通知cell丢失客户端
			Mercury::Bundle* pBundle = Mercury::Bundle::ObjPool().createObject();
			(*pBundle).newMessage(CellappInterface::onResetWitness);
			(*pBundle) << this->getID();
			getCellMailbox()->postMail((*pBundle));
			Mercury::Bundle::ObjPool().reclaimObject(pBundle);
		}

		entitiesEnabled_ = false;
		getClientMailbox()->addr(Mercury::Address::NONE);
		Py_DECREF(getClientMailbox());
		proxy->onGiveClientTo(lpChannel);
		setClientMailbox(NULL);
		addr(Mercury::Address::NONE);
		
		if(proxy->getClientMailbox() != NULL)
		{
			// 通知client销毁当前entity
			Mercury::Bundle* pBundle = Mercury::Bundle::ObjPool().createObject();
			(*pBundle).newMessage(ClientInterface::onEntityDestroyed);
			(*pBundle) << this->getID();
			proxy->getClientMailbox()->postMail((*pBundle));
			Mercury::Bundle::ObjPool().reclaimObject(pBundle);
		}
	}
}
Beispiel #2
0
void doSetUserRegions(struct sqlConnection *conn)
/* Respond to set regions button. */
{
char *oldPasted = cartUsualString(cart, hgtaEnteredUserRegions, "");
char *db = cartOptionalString(cart, hgtaUserRegionsDb);
if (db && !sameString(db, database))
    oldPasted = "";
htmlOpen("Enter region definition\n");
hPrintf("<FORM ACTION=\"%s\" METHOD=POST "
    " ENCTYPE=\"multipart/form-data\" NAME=\"mainForm\">\n", getScriptName());
cartSaveSession(cart);
hPrintf("<TABLE><TR><TD ALIGN=LEFT>\n");
hPrintf("Paste regions:");
hPrintf("</TD><TD ALIGN=RIGHT>");
hPrintf("Or upload file: <INPUT TYPE=FILE NAME=\"%s\">&nbsp;<BR>\n",
	hgtaEnteredUserRegionFile);
hPrintf("</TD></TR><TR><TD COLSPAN=2 ALIGN=LEFT>\n");
cgiMakeTextArea(hgtaEnteredUserRegions, oldPasted, 10, 70);
hPrintf("</TD></TR><TR><TD COLSPAN=2 ALIGN=LEFT>\n");
cgiMakeButton(hgtaDoSubmitUserRegions, "submit");
hPrintf("&nbsp;");
cgiMakeButton(hgtaDoClearSetUserRegionsText, "clear");
hPrintf("&nbsp;");
cgiMakeButton(hgtaDoMainPage, "cancel");
hPrintf("</TD></TR></TABLE>");
hPrintf("</FORM><BR>\n");
webIncludeHelpFile("hgTbUserRegionsHelp", FALSE);
htmlClose();
}
Beispiel #3
0
//-------------------------------------------------------------------------------------
void Proxy::onDefDataChanged(const PropertyDescription* propertyDescription, 
		PyObject* pyData)
{
	uint32 flags = propertyDescription->getFlags();

	if((flags & ED_FLAG_BASE_AND_CLIENT) <= 0 || clientMailbox_ == NULL)
		return;

	// 创建一个需要广播的模板流
	MemoryStream* mstream = MemoryStream::ObjPool().createObject();

	propertyDescription->getDataType()->addToStream(mstream, pyData);

	Mercury::Bundle* pBundle = Mercury::Bundle::ObjPool().createObject();
	(*pBundle).newMessage(ClientInterface::onUpdatePropertys);
	(*pBundle) << getID();

	if(scriptModule_->usePropertyDescrAlias())
		(*pBundle) << propertyDescription->aliasIDAsUint8();
	else
		(*pBundle) << propertyDescription->getUType();

	pBundle->append(*mstream);
	
	g_privateClientEventHistoryStats.trackEvent(getScriptName(), 
		propertyDescription->getName(), 
		pBundle->currMsgLength());

	sendToClient(ClientInterface::onUpdatePropertys, pBundle);
	MemoryStream::ObjPool().reclaimObject(mstream);
}
Beispiel #4
0
void genomicFormatPage(struct sqlConnection *conn)
/* Put up page asking for what sort of genomic sequence. */
{
struct hTableInfo *hti = getHti(database, curTable, conn);
htmlOpen("%s Genomic Sequence", curTableLabel());
if (doGalaxy())
    startGalaxyForm();
else
    hPrintf("<FORM ACTION=\"%s\" METHOD=GET>\n", getScriptName());
cartSaveSession(cart);
hgSeqOptionsHtiCart(hti, cart);
hPrintf("<BR>\n");
if (doGalaxy())
    {
    /* pass parameter to get sequence to Galaxy */
    cgiMakeHiddenVar(hgtaDoGenomicDna, "get sequence");
    printGalaxySubmitButtons();
    }
else
    {
    cgiMakeButton(hgtaDoGenomicDna, "get sequence");
    hPrintf(" ");
    cgiMakeButton(hgtaDoMainPage, "cancel");
    hPrintf("</FORM>");
    }
cgiDown(0.9);
htmlClose();
}
Beispiel #5
0
//-------------------------------------------------------------------------------------
PyObject* Proxy::pyClientAddr()
{ 
	if(isDestroyed())	
	{
		PyErr_Format(PyExc_AssertionError, "%s: %d is destroyed!\n",		
			getScriptName(), getID());		
		PyErr_PrintEx(0);
		return 0;																				
	}

	PyObject* pyobj = PyTuple_New(2);

	if(getClientMailbox() == NULL || getClientMailbox()->getChannel() == NULL || 
		getClientMailbox()->getChannel()->endpoint() == NULL)
	{
		PyTuple_SetItem(pyobj, 0, PyLong_FromLong(0));
		PyTuple_SetItem(pyobj, 1, PyLong_FromLong(0));
	}
	else
	{
		const Mercury::Address& addr = getClientMailbox()->getChannel()->endpoint()->addr();
		PyTuple_SetItem(pyobj, 0, PyLong_FromUnsignedLong(addr.ip));
		PyTuple_SetItem(pyobj, 1, PyLong_FromUnsignedLong(addr.port));
	}

	return pyobj;
}
Beispiel #6
0
void doUploadIdentifiers(struct sqlConnection *conn)
/* Respond to upload identifiers button. */
{
struct hTableInfo *hti = maybeGetHti(database, curTable, conn);
char *idField = getIdField(database, curTrack, curTable, hti);
htmlOpen("Upload Identifiers for %s", curTableLabel());
if (idField == NULL)
    errAbort("Sorry, I can't tell which field of table %s to treat as the "
	     "identifier field.", curTable);
hPrintf("<FORM ACTION=\"%s\" METHOD=POST ENCTYPE=\"multipart/form-data\">\n",
	getScriptName());
cartSaveSession(cart);
hPrintf("Please enter the name of a file from your computer that contains a ");
hPrintf("space, tab, or ");
hPrintf("line separated list of the items you want to include.\n");
explainIdentifiers(database, conn, idField);
hPrintf("<BR>\n");
hPrintf("<INPUT TYPE=FILE NAME=\"%s\"> ", hgtaPastedIdentifiers);
hPrintf("<BR>\n");
cgiMakeButton(hgtaDoPastedIdentifiers, "submit");
hPrintf(" ");
cgiMakeButton(hgtaDoMainPage, "cancel");
hPrintf("</FORM>");
cgiDown(0.9);
htmlClose();
}
Beispiel #7
0
//-------------------------------------------------------------------------------------
PyObject* Entity::pyTeleport(PyObject* nearbyMBRef, PyObject* pyposition, PyObject* pydirection)
{
	if(!PySequence_Check(pyposition) || PySequence_Size(pyposition) != 3)
	{
		PyErr_Format(PyExc_Exception, "%s::teleport: %d position not is Sequence!\n", getScriptName(), getID());
		PyErr_PrintEx(0);
		S_Return;
	}

	if(!PySequence_Check(pydirection) || PySequence_Size(pydirection) != 3)
	{
		PyErr_Format(PyExc_Exception, "%s::teleport: %d direction not is Sequence!\n", getScriptName(), getID());
		PyErr_PrintEx(0);
		S_Return;
	}

	Position3D pos;
	Direction3D dir;

	PyObject* pyitem = PySequence_GetItem(pyposition, 0);
	pos.x = (float)PyFloat_AsDouble(pyitem);
	Py_DECREF(pyitem);

	pyitem = PySequence_GetItem(pyposition, 1);
	pos.y = (float)PyFloat_AsDouble(pyitem);
	Py_DECREF(pyitem);

	pyitem = PySequence_GetItem(pyposition, 2);
	pos.z = (float)PyFloat_AsDouble(pyitem);
	Py_DECREF(pyitem);

	pyitem = PySequence_GetItem(pydirection, 0);
	dir.roll = (float)PyFloat_AsDouble(pyitem);
	Py_DECREF(pyitem);

	pyitem = PySequence_GetItem(pydirection, 1);
	dir.pitch = (float)PyFloat_AsDouble(pyitem);
	Py_DECREF(pyitem);

	pyitem = PySequence_GetItem(pydirection, 2);
	dir.yaw = (float)PyFloat_AsDouble(pyitem);
	Py_DECREF(pyitem);
	
	teleport(nearbyMBRef, pos, dir);
	S_Return;
}
Beispiel #8
0
//-------------------------------------------------------------------------------------
void Proxy::giveClientTo(Proxy* proxy)
{
	Mercury::Channel* lpChannel = clientMailbox_->getChannel();
	if(lpChannel == NULL)
	{
		char err[255];																				
		kbe_snprintf(err, 255, "Proxy[%s]::giveClientTo: no has client.\n", getScriptName());			
		PyErr_SetString(PyExc_TypeError, err);														
		PyErr_PrintEx(0);	
		onGiveClientToFailure();
		return;
	}

	if(proxy)
	{
		EntityMailbox* mb = proxy->getClientMailbox();
		if(mb != NULL)
		{
			ERROR_MSG("Proxy::giveClientTo: %s[%ld] give client to %s[%ld], %s have clientMailbox.", 
					getScriptName(), 
					getID(), 
					proxy->getScriptName(), 
					proxy->getID(), 
					proxy->getScriptName());

			onGiveClientToFailure();
			return;
		}

		if(getCellMailbox())
		{
			// 通知cell丢失客户端
			Mercury::Bundle* pBundle = Mercury::Bundle::ObjPool().createObject();
			(*pBundle).newMessage(CellappInterface::onLoseWitness);
			getCellMailbox()->postMail((*pBundle));
			Mercury::Bundle::ObjPool().reclaimObject(pBundle);
		}

		getClientMailbox()->addr(Mercury::Address::NONE);
		Py_DECREF(getClientMailbox());
		proxy->onGiveClientTo(lpChannel);
		setClientMailbox(NULL);
		addr(Mercury::Address::NONE);
	}
}
Beispiel #9
0
std::string
RotoItem::getFullyQualifiedName() const
{
    std::string name = getScriptName();
    boost::shared_ptr<RotoLayer> parent = getParentLayer();
    if (parent) {
        getScriptNameRecursive(parent.get(), &name);
    }
    return name;
}
Beispiel #10
0
//-------------------------------------------------------------------------------------
bool Entity::navigateStep(const Position3D& destination, float velocity, float maxMoveDistance, float maxDistance, 
	bool faceMovement, float girth, PyObject* userData)
{
	DEBUG_MSG(boost::format("Entity[%1%:%2%]:destination=(%3%,%4%,%5%), velocity=%6%, maxMoveDistance=%7%, "
		"maxDistance=%8%, faceMovement=%9%, girth=%10%, userData=%11%.\n") %
		getScriptName() % id_ % destination.x % destination.y % destination.z % velocity % maxMoveDistance %
		maxDistance % faceMovement % girth % userData);

	return true;
}
Beispiel #11
0
//-------------------------------------------------------------------------------------
PyObject* Base::createCellEntity(PyObject* pyobj)
{
	if(isDestroyed())																				
	{																										
		PyErr_Format(PyExc_Exception, "%s::createCellEntity: %d is destroyed!\n",											
			getScriptName(), getID());												
		PyErr_PrintEx(0);																					
		S_Return;																								
	}																										

	if(Baseapp::getSingleton().findEntity(getID()) == NULL)
	{
		PyErr_Format(PyExc_Exception, "%s::createCellEntity: %d not found!\n", getScriptName(), getID());
		PyErr_PrintEx(0);
		S_Return;
	}

	if(creatingCell_ || this->getCellMailbox())
	{
		PyErr_Format(PyExc_Exception, "%s::createCellEntity: %d has a cell!\n", getScriptName(), getID());
		PyErr_PrintEx(0);
		S_Return;
	}

	if(!PyObject_TypeCheck(pyobj, EntityMailbox::getScriptType()))
	{
		PyErr_Format(PyExc_TypeError, "create %s arg1 is not cellMailbox!", this->getScriptName());
		PyErr_PrintEx(0);
		S_Return;
	}
	
	EntityMailboxAbstract* cellMailbox = static_cast<EntityMailboxAbstract*>(pyobj);
	if(cellMailbox->getType() != MAILBOX_TYPE_CELL)
	{
		PyErr_Format(PyExc_TypeError, "create %s args1 not is a direct cellMailbox!", this->getScriptName());
		PyErr_PrintEx(0);
		S_Return;
	}
	
	creatingCell_ = true;
	Baseapp::getSingleton().createCellEntity(cellMailbox, this);
	S_Return;
}
Beispiel #12
0
//-------------------------------------------------------------------------------------
void Base::onRemoteMethodCall(Mercury::Channel* pChannel, MemoryStream& s)
{
	// 如果是外部通道调用则判断来源性
	if(pChannel->isExternal())
	{
		ENTITY_ID srcEntityID = pChannel->proxyID();
		if(srcEntityID <= 0 || srcEntityID != this->getID())
		{
			WARNING_MSG("Base::onRemoteMethodCall: srcEntityID:%d, thisEntityID:%d.\n", srcEntityID, this->getID());
			return;
		}
	}

	if(isDestroyed())																				
	{																										
		ERROR_MSG("%s::onRemoteMethodCall: %d is destroyed!\n",											
			getScriptName(), getID());
		s.read_skip(s.opsize());
		return;																							
	}

	ENTITY_METHOD_UID utype = 0;
	s >> utype;
	
	MethodDescription* md = scriptModule_->findBaseMethodDescription(utype);
	if(md == NULL)
	{
		ERROR_MSG("Base::onRemoteMethodCall: can't found method. utype=%u, callerID:%d.\n", utype, id_);
		return;
	}

	DEBUG_MSG("Base::onRemoteMethodCall: entityID:%d, methodType:%s(%u).\n", 
		id_, md->getName(), utype);

	md->currCallerID(this->getID());
	PyObject* pyFunc = PyObject_GetAttrString(this, const_cast<char*>
						(md->getName()));

	if(md != NULL)
	{
		PyObject* pyargs = md->createFromStream(&s);
		if(pyargs)
		{
			md->call(pyFunc, pyargs);
			Py_XDECREF(pyargs);
		}
		else
		{
			SCRIPT_ERROR_CHECK();
		}
	}
	
	Py_XDECREF(pyFunc);
}
Beispiel #13
0
//-------------------------------------------------------------------------------------
PyObject* Proxy::pyGetTimeSinceHeardFromClient()
{ 
	if(isDestroyed())	
	{
		PyErr_Format(PyExc_AssertionError, "%s: %d is destroyed!\n",		
			getScriptName(), getID());		
		PyErr_PrintEx(0);
		return 0;																					
	}
	
	return PyFloat_FromDouble(this->getTimeSinceHeardFromClient()); 
}
Beispiel #14
0
//-------------------------------------------------------------------------------------
PyObject* Base::createInNewSpace(PyObject* params)
{
	if(isDestroyed())																				
	{																										
		PyErr_Format(PyExc_Exception, "%s::createInNewSpace: %d is destroyed!\n",											
			getScriptName(), getID());												
		PyErr_PrintEx(0);																					
		S_Return;																								
	}	

	if(createdSpace_)
	{
		PyErr_Format(PyExc_Exception, "%s::createInNewSpace: %d has a space!\n", getScriptName(), getID());
		PyErr_PrintEx(0);
		S_Return;
	}

	createdSpace_ = true;
	Baseapp::getSingleton().createInNewSpace(this, params);
	S_Return;
}
Beispiel #15
0
static void genePredOptions(struct trackDb *track, char *type,
	struct sqlConnection *conn)
/* Put up sequence type options for gene prediction tracks. */
{
char *predType = cartUsualString(cart, hgtaGeneSeqType, genePredMenu[0]);
char *dupType = cloneString(type);
char *typeWords[3];
int typeWordCount, typeIx;

/* Type field has 1-3 words which are in order:
 *     genePred pepTable mrnaTable */
typeWordCount = chopLine(dupType, typeWords);
/* TypeIx will be 0 (genomic) 1 (protein) 2(mrna). */
typeIx = stringArrayIx(predType, genePredMenu, typeWordCount);
if (typeIx < 0)
    predType = genePredMenu[0];
htmlOpen("Select sequence type for %s", track->shortLabel);
hPrintf("<FORM ACTION=\"%s\" METHOD=GET>\n", getScriptName());
cartSaveSession(cart);

if (isRefGeneTrack(track->table))
    {
    /* RefGene covers all 3 types, but in it's own way. */
    for (typeIx = 0; typeIx < 3; ++typeIx)
	{
	genePredTypeButton(genePredMenu[typeIx], predType);
	hPrintf(" %s<BR>\n", genePredMenu[typeIx]);
	}
    }
else
    {
    /* Otherwise we always have genomic, and we have
     * peptide/mrna only if there are corresponding table
     * in the type field. */
    for (typeIx = 0; typeIx < typeWordCount; ++typeIx)
	{
	if (typeIx == 0 || sqlTableExists(conn, typeWords[typeIx]))
	    {
	    genePredTypeButton(genePredMenu[typeIx], predType);
	    hPrintf(" %s<BR>\n", genePredMenu[typeIx]);
	    }
	}
    }
cgiMakeButton(hgtaDoGenePredSequence, "submit");
hPrintf(" ");
cgiMakeButton(hgtaDoMainPage, "cancel");
hPrintf("</FORM>\n");
cgiDown(0.9);
htmlClose();
freez(&dupType);
}
BOOL CModuleType::save()
{
	char	sysDirScripts	[FILE_MAX_PATHLEN];
	char	sysDirModules	[FILE_MAX_PATHLEN];
	char	sysDirIcons		[FILE_MAX_PATHLEN];

	if (RegKeyGetValue(REGKEY_SECTION_PATHNAME, REGKEY_KEY_SCRIPTS_PATHNAME,	sysDirScripts) == FALSE)
		strcpy(sysDirScripts, "scripts\\");
	if (RegKeyGetValue(REGKEY_SECTION_PATHNAME, REGKEY_KEY_MODULES_PATHNAME,	sysDirModules) == FALSE)
		strcpy(sysDirModules, "modules\\");
	if (RegKeyGetValue(REGKEY_SECTION_PATHNAME, REGKEY_KEY_ICONS_PATHNAME,		sysDirIcons) == FALSE)
		strcpy(sysDirIcons, "icons\\");

	char	outFnameScripts	[FILE_MAX_FILENAME];
	char	outFnameModules	[FILE_MAX_FILENAME];
	char	outFnameIcons	[FILE_MAX_FILENAME];

	sprintf(outFnameModules, "%s%s%s.%s", sysDirModules, getClassName(), getName(), MODULE_FILE_EXTENTION);
	strcpy(outFnameScripts, getScriptName());	FileChangePathName(outFnameScripts, sysDirScripts);
	sprintf(outFnameIcons, "%s%s%s.%s", sysDirIcons, getClassName(), getName(), ICON_FILE_EXTENTION);

	// Copy a icon and script files into system directry.
	BOOL bCopiedScriptFile = FileCopy(getScriptName(), outFnameScripts);
	BOOL bCopiedIconFile = FileCopy(getIconName(), outFnameIcons);
	
	if (!bCopiedScriptFile || !bCopiedIconFile)
		return FALSE;

	// Strip the directory name in a icon and scrpit file name.
	char	scriptFilename	[FILE_MAX_FILENAME];
	char	iconFilename	[FILE_MAX_FILENAME];
	strcpy(scriptFilename, getScriptName());	FileStripPathName(scriptFilename);	setScriptName(scriptFilename);
	sprintf(iconFilename, "%s%s.%s", getClassName(), getName(), ICON_FILE_EXTENTION);	setIconName(iconFilename);

	// Save this module infomation into a file
	return save(outFnameModules);
}
BOOL CModuleType::save(char *fname) 
{
	if (!isOK())
		return FALSE;

	ofstream fout(fname);
	if (!fout)
		return FALSE;

	fout << "#CTB MODULETYPE V1.0" << endl;

	fout << "CLASSNAME " << ((getClassName() && strlen(getClassName()) > 0) ? getClassName() : "NULL") << endl; 
	fout << "MODULENAME " << ((getName() && strlen(getName()) > 0) ? getName() : "NULL") << endl; 
	fout << "ATTRIBUTE " << ((getAttribure() == MODULETYPE_ATTRIBUTE_SYSTEM) ? "SYSTEM" : "USER") << endl; 
	fout << "SCRIPTNAME " << ((getScriptName() && strlen(getScriptName()) > 0) ? getScriptName() : "NULL") << endl; 
	fout << "ICONNAME " << ((getIconName() && strlen(getIconName()) > 0) ? getIconName() : "NULL") << endl; 

	int	n;
	for (n=0; n<MODULE_INOUTNODE_MAXNUM; n++) {
		char *fieldTypeName	= mEventInType[n]->getTypeName();
		char *fieldName		 = mEventInType[n]->getName();
		fout << "EVENTIN" << n << " " << (fieldTypeName ? fieldTypeName : "NULL") << " " << (fieldName ? fieldName : "NULL") << endl; 
	}

	for (n=0; n<MODULE_INOUTNODE_MAXNUM; n++) {
		char *fieldTypeName	= mEventOutType[n]->getTypeName();
		char *fieldName		 = mEventOutType[n]->getName();
		fout << "EVENTOUT" << n << " " << (fieldTypeName ? fieldTypeName : "NULL") << " " << (fieldName ? fieldName : "NULL") << endl; 
	}

	fout << "EXECUTIONNODE " << (hasExecutionNode() ? "TRUE" : "FALSE") << endl; 
/*
	fout << "TARGETNODE " <<  getTargetNodeFieldTypeName() << " " << getTargetNodeFieldName() << endl; 
*/
	return TRUE;
}
Beispiel #18
0
//-------------------------------------------------------------------------------------
void Entity::onRemoteMethodCall(Mercury::Channel* pChannel, MemoryStream& s)
{
	SCOPED_PROFILE(SCRIPTCALL_PROFILE);

	if(isDestroyed())																				
	{																										
		ERROR_MSG(boost::format("%1%::onRemoteMethodCall: %2% is destroyed!\n") %											
			getScriptName() % getID());

		s.read_skip(s.opsize());
		return;																							
	}

	ENTITY_METHOD_UID utype = 0;
	s >> utype;
	
	DEBUG_MSG(boost::format("Entity::onRemoteMethodCall: entityID %1%, methodType %2%.\n") % 
				id_ % utype);
	
	MethodDescription* md = scriptModule_->findCellMethodDescription(utype);
	
	if(md == NULL)
	{
		ERROR_MSG(boost::format("Entity::onRemoteMethodCall: can't found method. utype=%1%, callerID:%2%.\n") % utype % id_);
		return;
	}

	md->currCallerID(this->getID());

	PyObject* pyFunc = PyObject_GetAttrString(this, const_cast<char*>
						(md->getName()));

	if(md != NULL)
	{
		PyObject* pyargs = md->createFromStream(&s);
		if(pyargs)
		{
			md->call(pyFunc, pyargs);
			Py_XDECREF(pyargs);
		}
		else
		{
			SCRIPT_ERROR_CHECK();
		}
	}
	
	Py_XDECREF(pyFunc);
}
Beispiel #19
0
NATRON_NAMESPACE_ENTER

void
TabWidgetI::toSerialization(SERIALIZATION_NAMESPACE::SerializationObjectBase* serializationBase)
{
    SERIALIZATION_NAMESPACE::TabWidgetSerialization* serialization = dynamic_cast<SERIALIZATION_NAMESPACE::TabWidgetSerialization*>(serializationBase);
    if (!serialization) {
        return;
    }

    serialization->tabs = getTabScriptNames();
    serialization->scriptName = getScriptName();
    serialization->isAnchor = isAnchor();
    serialization->currentIndex = activeIndex();

}
Beispiel #20
0
//-------------------------------------------------------------------------------------
PyObject* Proxy::pyGetEntitiesEnabled()
{ 
	if(isDestroyed())	
	{
		PyErr_Format(PyExc_AssertionError, "%s: %d is destroyed!\n",		
			getScriptName(), getID());		
		PyErr_PrintEx(0);
		return 0;																				
	}

	if(this->entitiesEnabled())
	{
		Py_RETURN_TRUE;
	}

	Py_RETURN_FALSE;
}
Beispiel #21
0
//-------------------------------------------------------------------------------------
PyObject* Base::pyGetClientMailbox()
{
	if(isDestroyed())	
	{
		PyErr_Format(PyExc_Exception, "%s: %d is destroyed!\n",		
			getScriptName(), getID());		
		PyErr_PrintEx(0);
		S_Return;																						
	}

	EntityMailbox* mailbox = getClientMailbox();
	if(mailbox == NULL)
		S_Return;

	Py_INCREF(mailbox);
	return mailbox; 
}
Beispiel #22
0
//-------------------------------------------------------------------------------------
PyObject* Proxy::pyGiveClientTo(PyObject* pyOterProxy)
{
	if(this->isDestroyed())
	{
		PyErr_Format(PyExc_AssertionError, "%s: %d is destroyed!\n",		
			getScriptName(), getID());		
		PyErr_PrintEx(0);
		return 0;
	}

	// 如果为None 则设置为NULL
	Proxy* oterProxy = NULL;
	if(pyOterProxy != Py_None)
		oterProxy = static_cast<Proxy*>(pyOterProxy);
	
	giveClientTo(oterProxy);
	S_Return;
}
Beispiel #23
0
void CGI::logCGIData(const QString& filename)
{
	// create a QFile object to do the file I/O
	QFile file(filename);

	// open the file
	if (file.open(QIODevice::WriteOnly))
	{
		// create a QTextStream object on the file
		Q3TextStream textFile(&file);

		// get the environment
		textFile << "REQUEST_METHOD=" << getenv("REQUEST_METHOD") << endl;
		textFile << "CONTENT_LENGTH=" << getenv("CONTENT_LENGTH") << endl;

		// write the query string to the file
		textFile << "QUERY_STRING=" << query_string << endl;

		// write misc. CGI environment pieces
		textFile << "AUTH_TYPE=" << getAuthType() << endl;
		textFile << "GATEWAY_INTERFACE=" << getGatewayInterface() << endl;
		textFile << "HTTP_ACCEPT=" << getHTTPAccept() << endl;
		textFile << "HTTP_ACCEPT_ENCODING=" << getHTTPAcceptEncoding() << endl;
		textFile << "HTTP_ACCEPT_LANGUAGE=" << getHTTPAcceptLanguage() << endl;
		textFile << "HTTP_CONNECTION=" << getHTTPConnection() << endl;
		textFile << "HTTP_REFERER=" << getHTTPReferer() << endl;
		textFile << "HTTP_USER_AGENT=" << getHTTPUserAgent() << endl;
		textFile << "REMOTE_HOST=" << getRemoteHost() << endl;
		textFile << "REMOTE_ADDRESS=" << getRemoteAddress() << endl;
		textFile << "REMOTE_PORT=" << getRemotePort() << endl;
		textFile << "REQUEST_URI=" << getRequestURI() << endl;
		textFile << "SCRIPT_NAME=" << getScriptName() << endl;
		textFile << "SERVER_ADMIN=" << getServerAdmin() << endl;
		textFile << "SERVER_NAME=" << getServerName() << endl;
		textFile << "SERVER_PORT=" << getServerPort() << endl;
		textFile << "SERVER_PROTOCOL=" << getServerProtocol() << endl;
		textFile << "SERVER_SOFTWARE=" << getServerSoftware() << endl;
	}

	// close the file
	file.close();

}
Beispiel #24
0
void doPasteIdentifiers(struct sqlConnection *conn)
/* Respond to paste identifiers button. */
{
struct sqlConnection *alternateConn = conn;
char *actualDb = database;
if (sameWord(curTable, WIKI_TRACK_TABLE))
    {
    alternateConn = wikiConnect();
    actualDb = wikiDbName();
    }

char *oldPasted = forCurTable() ?
    cartUsualString(cart, hgtaPastedIdentifiers, "") : "";
struct hTableInfo *hti = maybeGetHti(actualDb, curTable, conn);
char *idField = getIdField(actualDb, curTrack, curTable, hti);
htmlOpen("Paste In Identifiers for %s", curTableLabel());
if (idField == NULL)
    errAbort("Sorry, I can't tell which field of table %s to treat as the "
	     "identifier field.", curTable);
hPrintf("<FORM ACTION=\"%s\" METHOD=%s>\n", getScriptName(),
	cartUsualString(cart, "formMethod", "POST"));
cartSaveSession(cart);
hPrintf("Please paste in the identifiers you want to include.\n");
if (sqlDatabaseExists("hgTemp"))
    explainIdentifiers(actualDb, alternateConn, idField);
else
    warn("No hgTemp database found for temporary tables.<br>Please src/product/README.mysql.setup for more information.");
hPrintf("<BR>\n");
cgiMakeTextArea(hgtaPastedIdentifiers, oldPasted, 10, 70);
hPrintf("<BR>\n");
cgiMakeButton(hgtaDoPastedIdentifiers, "submit");
hPrintf(" ");
cgiMakeButton(hgtaDoClearPasteIdentifierText, "clear");
hPrintf(" ");
cgiMakeButton(hgtaDoMainPage, "cancel");
hPrintf("</FORM>");
cgiDown(0.9);
htmlClose();
if (sameWord(curTable, WIKI_TRACK_TABLE))
    wikiDisconnect(&alternateConn);
}
Beispiel #25
0
//-------------------------------------------------------------------------------------
PyObject* Base::pyDestroyEntity()
{
	if(isDestroyed())	
	{
		PyErr_Format(PyExc_Exception, "%s::destroy: %d is destroyed!\n",		
			getScriptName(), getID());		
		PyErr_PrintEx(0);
		S_Return;																						
	}

	if(creatingCell_ || cellMailbox_ != NULL) 
	{
		PyErr_Format(PyExc_Exception, "%s::destroy: id:%i has cell! creatingCell=%s\n", this->getScriptName(), this->getID(),
			creatingCell_ ? "true" : "false");
		PyErr_PrintEx(0);
	}
	else
		destroyEntity();

	S_Return;
}
Beispiel #26
0
//-------------------------------------------------------------------------------------
uint16 Entity::addProximity(float range)
{
	if(range <= 0.0f)
	{
		ERROR_MSG(boost::format("Entity::addProximity: range(%1%) <= 0.0f! entity[%2%:%3%]\n") % 
			range % getScriptName() % getID());

		return 0;
	}

	// 不允许范围大于cell边界
	if(range > CELL_BORDER_WIDTH)
		range = CELL_BORDER_WIDTH;

	/*
	// 在space中投放一个陷阱
	Proximity* p = new Proximity(this, range, 0.0f);
	trapMgr_.addProximity(p);
	if(currChunk_ != NULL)
		currChunk_->getSpace()->placeProximity(currChunk_, p);
	return p->getID();*/
	
	return 0;
}
Beispiel #27
0
void describeFields(char *db, char *table,
                    struct asObject *asObj, struct sqlConnection *conn)
/* Print out an HTML table showing table fields and types, and optionally
 * offering histograms for the text/enum fields. */
{
struct sqlResult *sr;
char **row;
#define TOO_BIG_FOR_HISTO 500000
boolean tooBig = (sqlTableSize(conn, table) > TOO_BIG_FOR_HISTO);
char query[256];
struct slName *exampleList, *example;
boolean showItemRgb = FALSE;

showItemRgb=bedItemRgb(findTdbForTable(db, curTrack, table, ctLookupName));
// should we expect itemRgb instead of "reserved"

sqlSafef(query, sizeof(query), "select * from %s limit 1", table);
exampleList = storeRow(conn, query);
sqlSafef(query, sizeof(query), "describe %s", table);
sr = sqlGetResult(conn, query);

hTableStart();
hPrintf("<TR><TH>field</TH>");
if (exampleList != NULL)
    hPrintf("<TH>example</TH>");
hPrintf("<TH>SQL type</TH> ");
if (!tooBig)
    hPrintf("<TH>info</TH> ");
if (asObj != NULL)
    hPrintf("<TH>description</TH> ");
puts("</TR>\n");
example = exampleList;
while ((row = sqlNextRow(sr)) != NULL)
    {
    if (showItemRgb && (sameWord(row[0],"reserved")))
	hPrintf("<TR><TD><TT>itemRgb</TT></TD> ");
    else
	hPrintf("<TR><TD><TT>%s</TT></TD> ", row[0]);
    if (exampleList != NULL)
        {
	hPrintf("<TD>");
	if (example != NULL)
	     hPrintf("%s", cleanExample(example->name));
	else
	     hPrintf("n/a");
	hPrintf("</TD>");
	}
    // enums/sets with many items can make for painfully wide rows in the table --
    // add spaces between quoted list values:
    if (stringIn("','", row[1]))
	{
	struct dyString *spaced = dyStringSub(row[1], "','", "', '");
	hPrintf("<TD><TT>%s</TT></TD>", spaced->string);
	}
    else
	hPrintf("<TD><TT>%s</TT></TD>", row[1]);
    if (!tooBig)
	{
	hPrintf(" <TD>");
	if ((isSqlStringType(row[1]) && !sameString(row[1], "longblob")) ||
	    isSqlEnumType(row[1]) || isSqlSetType(row[1]))
	    {
	    hPrintf("<A HREF=\"%s", getScriptName());
	    hPrintf("?%s", cartSidUrlString(cart));
	    hPrintf("&%s=%s", hgtaDatabase, db);
	    hPrintf("&%s=%s", hgtaHistoTable, table);
	    hPrintf("&%s=%s", hgtaDoValueHistogram, row[0]);
	    hPrintf("\">");
	    hPrintf("values");
	    hPrintf("</A>");
	    }
	else if (isSqlNumType(row[1]))
	    {
	    hPrintf("<A HREF=\"%s", getScriptName());
	    hPrintf("?%s", cartSidUrlString(cart));
	    hPrintf("&%s=%s", hgtaDatabase, db);
	    hPrintf("&%s=%s", hgtaHistoTable, table);
	    hPrintf("&%s=%s", hgtaDoValueRange, row[0]);
	    hPrintf("\">");
	    hPrintf("range");
	    hPrintf("</A>");
	    }
	else
	    {
	    hPrintf("&nbsp;");
	    }
	hPrintf("</TD>");
	}
    if (asObj != NULL)
        {
	struct asColumn *asCol = asColumnFind(asObj, row[0]);
	hPrintf(" <TD>");
	if (asCol != NULL)
	    hPrintf("%s", asCol->comment);
	else
	    {
	    if (sameString("bin", row[0]))
	       hPrintf("Indexing field to speed chromosome range queries.");
	    else
		hPrintf("&nbsp;");
	    }
	hPrintf("</TD>");
	}
    puts("</TR>");
    if (example != NULL)
	example = example->next;
    }
hTableEnd();
sqlFreeResult(&sr);
}
Beispiel #28
0
void doBedOrCtOptions(char *table, struct sqlConnection *conn,
                      boolean doCt)
/* Put up form to get options on BED or custom track output. */
/* (Taken from hgText.c/doBedCtOptions) */
{
char *table2 = NULL;	/* For now... */
struct hTableInfo *hti = getHti(database, table, conn);
char buf[256];
char *setting;
htmlOpen("Output %s as %s", table, (doCt ? "Custom Track" : "BED"));
if (doGalaxy())
    startGalaxyForm();
else if (doGreat())
    {
    verifyGreatAssemblies();
    startGreatForm();
    }
else
    hPrintf("<FORM ACTION=\"%s\" METHOD=GET>\n", getScriptName());
cartSaveSession(cart);
if (!doGreat())
{
    hPrintf("%s\n", "<TABLE><TR><TD>");
    if (doCt)
        {
        hPrintf("%s\n", "</TD><TD>"
                "<A HREF=\"../goldenPath/help/customTrack.html\" TARGET=_blank>"
                "Custom track</A> header: </B>");
        }
    else
        {
        cgiMakeCheckBox(hgtaPrintCustomTrackHeaders,
                        cartCgiUsualBoolean(cart, hgtaPrintCustomTrackHeaders, FALSE));
        hPrintf("%s\n", "</TD><TD> <B> Include "
                        "<A HREF=\"../goldenPath/help/customTrack.html\" TARGET=_blank>"
                        "custom track</A> header: </B>");
        }
    hPrintf("%s\n", "</TD></TR><TR><TD></TD><TD>name=");
    safef(buf, sizeof(buf), "tb_%s", hti->rootName);
    setting = cgiUsualString(hgtaCtName, buf);
    cgiMakeTextVar(hgtaCtName, setting, 16);
    hPrintf("%s\n", "</TD></TR><TR><TD></TD><TD>description=");
    safef(buf, sizeof(buf), "table browser query on %s%s%s",
          table, (table2 ? ", " : ""), (table2 ? table2 : ""));
    setting = cgiUsualString(hgtaCtDesc, buf);
    cgiMakeTextVar(hgtaCtDesc, setting, 50);
    hPrintf("%s\n", "</TD></TR><TR><TD></TD><TD>visibility=");
    if (isWiggle(database, table) || isBigWigTable(table))
        {
        setting = cartCgiUsualString(cart, hgtaCtVis, ctVisWigMenu[2]);
        cgiMakeDropList(hgtaCtVis, ctVisWigMenu, ctVisWigMenuSize, setting);
        }
    else
        {
        setting = cartCgiUsualString(cart, hgtaCtVis, ctVisMenu[3]);
        cgiMakeDropList(hgtaCtVis, ctVisMenu, ctVisMenuSize, setting);
        }
    hPrintf("%s\n", "</TD></TR><TR><TD></TD><TD>url=");
    setting = cartCgiUsualString(cart, hgtaCtUrl, "");
    cgiMakeTextVar(hgtaCtUrl, setting, 50);
    hPrintf("%s\n", "</TD></TR><TR><TD></TD><TD>");
    hPrintf("%s\n", "</TD></TR></TABLE>");
}
if (isWiggle(database, table) || isBedGraph(table) || isBigWigTable(table) )
    {
    char *setting = NULL;
    hPrintf("<P> <B> Select type of data output: </B> <BR>\n");
    setting = cartCgiUsualString(cart, hgtaCtWigOutType, outWigData);
    cgiMakeRadioButton(hgtaCtWigOutType, outWigBed, sameString(setting, outWigBed));
    hPrintf("BED format (no data value information, only position)<BR>\n");
    cgiMakeRadioButton(hgtaCtWigOutType, outWigData, sameString(setting, outWigData));
    hPrintf("DATA VALUE format (position and real valued data)</P>\n");
    }
else
    {
    cgiDown(0.9);
    hPrintf("<B> Create one BED record per: </B>\n");
    if ((anyIntersection() && intersectionIsBpWise()) ||
	(anySubtrackMerge(database, table) && subtrackMergeIsBpWise()))
	{
        /* The original table may have blocks/CDS, described in hti, but
         * that info will be lost after base pair-wise operations.  So make
         * a temporary copy of hti with its flags tweaked: */
	struct hTableInfo simplifiedHti;
	memcpy(&simplifiedHti, hti, sizeof(simplifiedHti));
	simplifiedHti.hasBlocks = FALSE;
	simplifiedHti.hasCDS = FALSE;
	fbOptionsHtiCart(&simplifiedHti, cart);
	}
    else
	fbOptionsHtiCart(hti, cart);
    }
if (doCt)
    {
    if (doGalaxy())
        {
        /* send the action parameter with the form as well */
        cgiMakeHiddenVar(hgtaDoGetCustomTrackFile, "get custom track in file");
        printGalaxySubmitButtons();
        }
    else
        {
        cgiMakeButton(hgtaDoGetCustomTrackTb, "get custom track in table browser");
        hPrintf(" ");
        cgiMakeButton(hgtaDoGetCustomTrackFile, "get custom track in file");
        hPrintf("<BR>\n");
        cgiMakeButton(hgtaDoGetCustomTrackGb, "get custom track in genome browser");
        }
    }
else
    {
    if (doGalaxy())
        {
        cgiMakeHiddenVar(hgtaDoGetBed, "get BED");
        printGalaxySubmitButtons();
        }
    else if (doGreat())
        {
        cgiMakeHiddenVar(hgtaDoGetBed, "get BED");
        printGreatSubmitButtons();
        }
    else
        cgiMakeButton(hgtaDoGetBed, "get BED");
    }
if (!doGalaxy() && !doGreat())
    {
    hPrintf(" ");
    cgiMakeButton(hgtaDoMainPage, "cancel");
    hPrintf("</FORM>\n");
    }
cgiDown(0.9);
htmlClose();
}
Beispiel #29
0
void startGreatForm()
/* Start form for GREAT */
{
hPrintf("<FORM ACTION=\"%s\" NAME='greatForm' METHOD=POST>\n", getScriptName());
}
Beispiel #30
0
void doIntersectMore(struct sqlConnection *conn)
/* Continue working in intersect page. */
{
struct trackDb *iTrack;
char *name = curTableLabel();
char *iName, *iTable;
char *onChange = onChangeEither();
char *op, *setting;
boolean wigOptions = (isWiggle(database, curTable) || isBedGraph(curTable));
// Note - bigWig is purposely left out of wigOptions.   It supports more intersection options
// than wig does.
struct hTableInfo *hti1 = maybeGetHti(database, curTable, conn), *hti2 = NULL;
htmlOpen("Intersect with %s", name);

hPrintf("<FORM ACTION=\"%s\" NAME=\"mainForm\" METHOD=GET>\n", getScriptName());
cartSaveSession(cart);
hPrintf("<TABLE BORDER=0>\n");
/* Print group and track line. */

hPrintf("Select a group, track and table to intersect with:\n");
iTrack = showGroupTrackRow(hgtaNextIntersectGroup, onChange,
	hgtaNextIntersectTrack, onChange, conn);
iName = iTrack->shortLabel;

hPrintf("<TR><TD>\n");
iTable = showTableField(iTrack, hgtaNextIntersectTable, FALSE);
hti2 = maybeGetHti(database, iTable, conn);
hPrintf("</TD></TR>\n");
hPrintf("</TABLE>\n");

if (!wigOptions)
    {
    if (hti1 && hti1->hasBlocks)
	hPrintf("<BR>Note: %s has gene/alignment structure.  "
		"Only the exons/blocks will be considered.\n", name);
    if (hti2 && hti2->hasBlocks)
	hPrintf("<BR>Note: %s has gene/alignment structure.  "
		"Only the bases covered by its exons/blocks will be "
		"considered.\n", iName);
    hPrintf("<H4>Intersect %s items with bases covered by %s:</H4>\n",
	    name, iName);
    hPrintf("These combinations will maintain the names and "
	    "gene/alignment structure (if any) of %s: <P>\n",
	    name);
    }
else
    hPrintf("<P>\n");

op = cartUsualString(cart, hgtaNextIntersectOp, "any");
jsTrackingVar("op", op);
makeOpButton("any", op);
printf("All %s records that have any overlap with %s <BR>\n",
       name, iName);
makeOpButton("none", op);
printf("All %s records that have no overlap with %s <BR>\n",
       name, iName);

if (!wigOptions)
    {
    makeOpButton("more", op);
    printf("All %s records that have at least ",
	   name);
    setting = cartCgiUsualString(cart, hgtaNextMoreThreshold, "80");
    cgiMakeTextVar(hgtaNextMoreThreshold, setting, 3);
    printf(" %% overlap with %s <BR>\n", iName);
    makeOpButton("less", op);
    printf("All %s records that have at most ",
	   name);
    setting = cartCgiUsualString(cart, hgtaNextLessThreshold, "80");
    cgiMakeTextVar(hgtaNextLessThreshold, setting, 3);
    printf(" %% overlap with %s <P>\n", iName);
    }
else
    {
    /*	keep javaScript onClick happy	*/
    hPrintf("<input TYPE=HIDDEN NAME=\"hgta_nextMoreThreshold\" VALUE=80>\n");
    hPrintf("<input TYPE=HIDDEN NAME=\"hgta_nextLessThreshold\" VALUE=80>\n");
    hPrintf(" <P>\n");
    }


if (!wigOptions)
    {
    boolean bigWig = isBigWigTable(curTable);
    hPrintf("<H4>Intersect bases covered by %s and/or %s:</H4>\n",
	    name, iName);
    if (!bigWig)
	hPrintf("These combinations will discard the names and "
		"gene/alignment structure (if any) of %s and produce a simple "
		"list of position ranges.<P>\n",
		name);
    makeOpButton("and", op);
    printf("Base-pair-wise intersection (AND) of %s and %s <BR>\n",
	name, iName);
    makeOpButton("or", op);
    printf("Base-pair-wise union (OR) of %s and %s <P>\n",
	name, iName);
    hPrintf("Check the following boxes to complement one or both tables.  "
	    "To complement a table means to include a base pair in the "
	    "intersection/union if it is <I>not</I> included in the table."
	    "<P>\n");
    if (!bigWig)
	{
	jsMakeTrackingCheckBox(cart, hgtaNextInvertTable, "invertTable", FALSE);
	printf("Complement %s before base-pair-wise intersection/union <BR>\n",
	       name);
	}
    jsMakeTrackingCheckBox(cart, hgtaNextInvertTable2, "invertTable2", FALSE);
    printf("Complement %s before base-pair-wise intersection/union <P>\n",
	   iName);
    }
else
    {
    /*	keep javaScript onClick happy	*/
    jsTrackingVar("op", op);
    hPrintf("<SCRIPT>\n");
    hPrintf("var invertTable=0;\n");
    hPrintf("var invertTable2=0;\n");
    hPrintf("</SCRIPT>\n");
    hPrintf("(data track %s is not composed of gene records.  Specialized intersection operations are not available.)<P>\n", name);
    }

cgiMakeButton(hgtaDoIntersectSubmit, "submit");
hPrintf(" ");
cgiMakeButton(hgtaDoMainPage, "cancel");
hPrintf("</FORM>\n");

/* Hidden form - for benefit of javascript. */
    {
    static char *saveVars[32];
    int varCount = ArraySize(nextVars);
    memcpy(saveVars, nextVars, varCount * sizeof(saveVars[0]));
    saveVars[varCount] = hgtaDoIntersectMore;
    jsCreateHiddenForm(cart, getScriptName(), saveVars, varCount+1);
    }

htmlClose();
}