Daily Archives

Articles indexed Monday June 7 2010

Page 3/113 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Python C API from C++ app - know when to lock

    - by Alex
    Hi Everyone, I am trying to write a C++ class that calls Python methods of a class that does some I/O operations (file, stdout) at once. The problem I have ran into is that my class is called from different threads: sometimes main thread, sometimes different others. Obviously I tried to apply the approach for Python calls in multi-threaded native applications. Basically everything starts from PyEval_AcquireLock and PyEval_ReleaseLock or just global locks. According to the documentation here when a thread is already locked a deadlock ensues. When my class is called from the main thread or other one that blocks Python execution I have a deadlock. Python Cfunc1() - C++ func that creates threads internally which lead to calls in "my class", It stuck on PyEval_AcquireLock, obviously the Python is already locked, i.e. waiting for C++ Cfunc1 call to complete... It completes fine if I omit those locks. Also it completes fine when Python interpreter is ready for the next user command, i.e. when thread is calling funcs in the background - not inside of a native call I am looking for a workaround. I need to distinguish whether or not the global lock is allowed, i.e. Python is not locked and ready to receive the next command... I tried PyGIL_Ensure, unfortunately I see hang. Any known API or solution for this ? (Python 2.4)

    Read the article

  • Are Django template tags cached?

    - by thebossman
    I have gone through the (painful) process of writing a custom template tag for use in Django. It is registered as an inclusion_tag so that it renders a template. However, this tag breaks as soon as I try to change something. I've tried changing the number of parameters and correspondingly changing the parameters when it's called. It's clear the new tag code isn't being loaded, because an error is thrown stating that there is a mismatch in the number of parameters, and it's evident that it's attempting to call the old function. The same problem occurs if I try to change the name of the template being rendered and correspondingly change the name of the template on disk. It continues to try to call the old template. I've tried clearing old .pyc files with no luck. Overall, the system is acting as though it's caching the template tags, likely due to the register command. I have dug through endless threads trying to find out if this is so, but all could find it James Bennett stating here that register doesn't do anything. Please help!

    Read the article

  • Search in Stack

    - by WPS
    Hi, I've a Java Stack created and some custom objects added to it. These objects contains unique id as one of their field. I need to get the index of that object in stack based on the unique name. Please find the example. class TestVO{ private String name; private String uniqueId; //getters and setters } public class TestStack{ public static void main(String args[]){ TestVO vo1=new TestVO(); TestVO vo2=new TestVO(); TestVO vo3=new TestVO(); vo1.setName("Test Name 1") vo1.setId("123") vo2.setName("Test name 2"); vo2.setId("234"); Stack<TestVO> stack=new Stack<TestVO>(); stack.add(vo1); stack.add(vo2); //I need to get the index of a VO from stack using it's unique ID } } Can someone please help me to implement this?

    Read the article

  • MediaWiki migrated from Tiger to Snow Leopard throwing an exceptions

    - by Matt S
    I had an old laptop running Mac OS X 10.4 with macports for web development: Apache 2, PHP 5.3.2, Mysql 5, etc. I got a new laptop running Mac OS X 10.6 and installed macports. I installed the same web development apps: Apache 2, PHP 5.3.2, Mysql 5, etc. All versions the same as my old laptop. A Mediawiki site (version 1.15) was copied over from my old system (via the Migration Assistant). Having a fresh Mysql setup, I dumped my old database and imported it on the new system. When I try to browse to mediawiki's "Special" pages, I get the following exception thrown: Invalid language code requested Backtrace: #0 /languages/Language.php(2539): Language::loadLocalisation(NULL) #1 /includes/MessageCache.php(846): Language::getFallbackFor(NULL) #2 /includes/MessageCache.php(821): MessageCache->processMessagesArray(Array, NULL) #3 /includes/GlobalFunctions.php(2901): MessageCache->loadMessagesFile('/Users/matt/Sit...', false) #4 /extensions/OpenID/OpenID.setup.php(181): wfLoadExtensionMessages('OpenID') #5 [internal function]: OpenIDLocalizedPageName(Array, 'en') #6 /includes/Hooks.php(117): call_user_func_array('OpenIDLocalized...', Array) #7 /languages/Language.php(1851): wfRunHooks('LanguageGetSpec...', Array) #8 /includes/SpecialPage.php(240): Language->getSpecialPageAliases() #9 /includes/SpecialPage.php(262): SpecialPage::initAliasList() #10 /includes/SpecialPage.php(406): SpecialPage::resolveAlias('UserLogin') #11 /includes/SpecialPage.php(507): SpecialPage::getPageByAlias('UserLogin') #12 /includes/Wiki.php(229): SpecialPage::executePath(Object(Title)) #13 /includes/Wiki.php(59): MediaWiki->initializeSpecialCases(Object(Title), Object(OutputPage), Object(WebRequest)) #14 /index.php(116): MediaWiki->initialize(Object(Title), NULL, Object(OutputPage), Object(User), Object(WebRequest)) #15 {main} I tried to step through Mediawiki's code, but it's a mess. There are global variables everywhere. If I change the code slightly to get around the exception, the page comes up blank and there are no errors (implying there are multiple problems). Anyone else get Mediawiki 1.15 working on OS X 10.6 with macports? Anything in the migration from Tiger that could cause a problem? Any clues where to look for answers?

    Read the article

  • Trying to sentinel loop this program.

    - by roger34
    Okay, I spent all this time making this for class but I have one thing that I can't quite get: I need this to sentinel loop continuously (exiting upon entering x) so that the System.out.println("What type of Employee? Enter 'o' for Office " + "Clerical, 'f' for Factory, or 's' for Saleperson. Enter 'x' to exit." ); line comes back up after they enter the first round of information. Also, I can't leave this up long on the (very) off chance a classmate might see this and steal the code. Full code following: import java.util.Scanner; public class Project1 { public static void main (String args[]){ Scanner inp = new Scanner( System.in ); double totalPay; System.out.println("What type of Employee? Enter 'o' for Office " + "Clerical, 'f' for Factory, or 's' for Saleperson. Enter 'x' to exit." ); String response= inp.nextLine(); while (!response.toLowerCase().equals("o")&&!response.toLowerCase().equals("f") &&!response.toLowerCase().equals("s")&&!response.toLowerCase().equals("x")){ System.out.print("\nInvalid selection,please enter your choice again:\n"); response=inp.nextLine(); } char choice = response.toLowerCase().charAt( 0 ); switch (choice){ case 'o': System.out.println("Enter your hourly rate:"); double officeRate=inp.nextDouble(); System.out.println("Enter the number of hours worked:"); double officeHours=inp.nextDouble(); totalPay = officeCalc(officeRate,officeHours); taxCalc(totalPay); break; case 'f': System.out.println("How many Widgets did you produce during the week?"); double widgets=inp.nextDouble(); totalPay=factoryCalc(widgets); taxCalc(totalPay); break; case 's': System.out.println("What were your total sales for the week?"); double totalSales=inp.nextDouble(); totalPay=salesCalc(totalSales); taxCalc(totalPay); break; } } public static double taxCalc(double totalPay){ double federal=totalPay*.22; double state =totalPay*.055; double netPay = totalPay - federal - state; federal =federal*Math.pow(10,2); federal =Math.round(federal); federal= federal/Math.pow(10,2); state =state*Math.pow(10,2); state =Math.round(state); state= state/Math.pow(10,2); totalPay =totalPay*Math.pow(10,2); totalPay =Math.round(totalPay); totalPay= totalPay/Math.pow(10,2); netPay =netPay*Math.pow(10,2); netPay =Math.round(netPay); netPay= netPay/Math.pow(10,2); System.out.printf("\nTotal Pay \t: %1$.2f.\n", totalPay); System.out.printf("State W/H \t: %1$.2f.\n", state); System.out.printf("Federal W/H : %1$.2f.\n", federal); System.out.printf("Net Pay \t: %1$.2f.\n", netPay); return totalPay; } public static double officeCalc(double officeRate,double officeHours){ double overtime=0; if (officeHours>=40) overtime = officeHours-40; else overtime = 0; if (officeHours >= 40) officeHours = 40; double otRate = officeRate * 1.5; double totalPay= (officeRate * officeHours) + (otRate*overtime); return totalPay; } public static double factoryCalc(double widgets){ double totalPay=widgets*.35 +300; return totalPay; } public static double salesCalc(double totalSales){ double totalPay = totalSales * .05 + 500; return totalPay; } }

    Read the article

  • Mouse configurable buttons for programming

    - by DavRob60
    Different mouse models has been already discussed. But all these mouse got configurable buttons. Has a programmer, how do you set them? I use The Microsoft Intellimouse Optical. So set the Left side button to "Copy" and the Right side button to "Paste". I did not set the Wheel click to anything. I'm curious to see if there is any better setup? UPDATE : I'm trying to find some interesting key I could map to my mouse buttons. Copy & paste are the best I' found so far, but i just want to know if there is something that could be more useful when programming.

    Read the article

  • Drupal Translate in Admin not working

    - by Chris
    I have the View/Edit/Translate links in the admin section when editing an article. However, when I click on translate, the link admin/node/65/translate just takes me to the homepage, while admin/node/65/edit lets me edit the article. Is there a Pathauto setting I'm missing to allow me to translate the page?

    Read the article

  • Drawing widgets (such as buttons) over QGraphicsView

    - by Aditya Bhatt
    How do I draw interactive widgets such as QButtons and Line Edits over a QGraphicsView? For ex, I have selected a region over an image in an image editing app which displays an image with QGraphicsView, and I want to annotate this region with a name. So I want to have a Line edit and two buttons (Cross and Tick) below this rectangular selection. How do I draw these? Sample code would be cool!

    Read the article

  • Resizing a GLContext in Windows

    - by user146780
    I have a Win32 window and it has a gl context. I'm trying to figure out how to resize the context because even if I use glviewport it still stays the same size as when I created the context. Am I misunderstanding glviewport? i'm providing it the bottom left corner and the size I want but its still the original size that I made the context. Thanks

    Read the article

  • Effective Android Programming Techniques

    - by kunjaan
    Please Help me compile a list of Effective Android Programming techniques Don't forget to free resources after use. Lot of resources like Cursors are overlooked. Free them too. Don't Use magic Numbers. values[0] is meaningless. The framework provides very useful accessors like values[SensorManager.DATA_X] "Make use of onPause()/onResume to save or close what does not need to be opened the whole time." protected void onResume() { mSensorManager.registerListener(...); } protected void onStop() { mSensorManager.unregisterListener(...); super.onStop(); } Make your Android UI Fast and Efficient from the Google I/O has a lot of useful UI Performance tips.

    Read the article

  • simple php Dollar $ evaluation in string questions

    - by Mirage
    I have always been confused that .e,g in php i have sql statement $qry = "select * from table where id = $id"; now can i insert "$" directly inside the quotes or i have to use $qry = "select * from table where id =".$id." "; or $qry = 'select * from table where id = $id'; or $qry = 'select * from table where id = '$id''; Which is correct

    Read the article

  • How to write a CXF client with implicit security header.

    - by Jayaprakash
    Hi everyone, I have to access a service which is developed using different framework. The client program is using CXF. I dont have access to the provider environment so I cannot use any config files (Cxf.xml, cxfservlet.xml etc..). I need to access the webservice with implicit security header (UsernameTokenType, oasis-200401-wss-wssecurity-secext-1.0.xsd) . Can anyone throw some light on this?..

    Read the article

  • Add onchange event to a "locked" field in Dynamics CRM 4

    - by Evgeny
    I'm customising Dynamics CRM 4 and would like to modify the Form for the Case entity to add some JavaScript to the onchange event for the Knowledge Base Article lookup field (kbarticleid_ledit). However, when I click Change Properties for that field I get an error message: This field belongs to a locked section and cannot have its properties modified. How can I get around this and edit it? Is there a workaround similar to customizing the Article view? Or can I hack the DB somehow to "unlock" that field?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >