Why conditionalPanel does not work on first attempt? - shiny

In my shiny webapp I put some conditionalPanel in various tabPanel like this:
On UI side:
tabPanel("Loading & parsing samples",
actionButton("runLoad"),
conditionalPanel(
condition = ("output.load_panelStatus"),
h3("Push to get some summaries of the samples loaded"),
...)
)
On server side
observeEvent(eventExpr = input$runLoad, {
...
output$load_panelStatus <- reactive({input$load_panelStatus=="show"})
outputOptions(output, "load_panelStatus", suspendWhenHidden = FALSE)
print("Parsing process ends")
output$console_output_pre <- renderPrint("parsing process ends")
})
Strangely enough this worked perfectly up to some two days ago but now (even when I test it on my old source versions) I have to press twice the runLoad button in order to let UI showing the remaining of the output (the h3("") statement and all the rest of the output ...).
In the meantime I only performed only some package update but nothing that should affect the shiny app... (at least I guess)
I wander if somebody else has met recently this type of problem

The problem was on shinycssloaders. The new version 0.3.0. does not work properly

Related

Shiny downloadButton() and downloadHandler() 500 Error

I have developed a Shiny Dashboard, I have several data frames that get imported through reactive file readers, etc.. I have also added a "Generate PDF" button, using downloadButton() in my ui.R code. My server.R code implements the downloadHandler() to handle that request.
On my Windows desktop this all works perfectly. I want this to run on a Linux server I have setup. I had to modify some paths, of course, and Shiny Server runs as root on this box. When I click the "Generate PDF" button on site running on the Linux server, I get an HTTP 500 error almost instantly. I have manually compiled the pdfReport.Rmd file on the Linux server myself and it runs just fine.
I am guessing one of two things:
Somehow the data isn't getting passed the same way on the Linux box as it does on the Windows desktop. This is probably not likely, but it is a possibility.
I have something wrong with my paths so when the temp files get written to start generating the PDF, the system doesn't have the ability or a path doesn't exist to write the file. Possibly my downloadHandler() code is malformed in some way. I think this is a higher possibility than the #1.
Here is my code for the downloadHandler():
output$pdfReport <- downloadHandler(
# For PDF output, change this to "report.pdf"
filename = reactive({paste0("/srv/shiny-server/itpod/","ITPOD-",Sys.Date(),".pdf")}),
content = function(file) {
# Copy the report file to a temporary directory before processing it, in
# case we don't have write permissions to the current working dir (which
# can happen when deployed).
tempReport <- file.path("/srv/shiny-server/itpod", "pdfReport.Rmd")
file.copy("report.Rmd", tempReport, overwrite = TRUE)
params <- list(ilp=updateILP(), ico=updateICO(), sec=updateSecurity(), ppwc=updateWorkPreviousPeriodCompleted(),
pow=updateOngoingWorkCABApproved(), pwcr=updatePlannedWorkCABRequested(), epca=updateEmergencyChangesPendingCABApproval(),
fac=updateFacilities(), drs=updateDRStatus(), ov=updateOperationalEvents(), sl=updateStaffLocations(),
w = updateWeather())
# Knit the document, passing in the `params` list, and eval it in a
# child of the global environment (this isolates the code in the document
# from the code in this app).
rmarkdown::render(tempReport, output_file = file, params = params, envir = new.env(parent = globalenv())
)
}
)
I thought maybe that the path just wasn't writeable, so I tried changing that to /tmp, but that didn't work either. Poking around, I discovered that when I over the "Generate PDF" button, I get a long URL with a "session":
http://my.url.com:3838/itpod/session/d661a858f5679aba26692bc9b4442872/download/pdfReport?w=
I'm starting to wonder if this is the issue and that I'm not writing to a path of the current session or something? This is a new area to me with Shiny. Like I said, on my desktop it works fine, but once I deploy it to the Linux server, it doesn't work correctly. Any help would be much appreciated. Thanks in advance!
Ok - after much troubleshooting, I figured out that some of the files I had in the shiny webroot that were dependencies for the main pdfReport.Rmd file weren't being seen, since the code copied the report to a temp directory.
Because I didn't want to copy all of the files from my webroot over to the temp, I decided to make the report render within the webroot itself. For me, this isn't a big deal since my shiny app is running as root anyway.
I will fix this now that I have it working, basically my fix will be to do the following:
Make the service run as a normal user
Rather than copy of the files that the report depends on, I will have to statically reference them in the report code.
I apologize for all of those who may have read this and are working on it. My fix was to the code above was the following:
output$pdfReport <- downloadHandler(
# For PDF output, change this to "report.pdf"
filename = reactive({paste0("/srv/shiny-server/itpod/","ITPOD-",Sys.Date(),".pdf")}),
content = function(file) {
# Copy the report file to a temporary directory before processing it, in
# case we don't have write permissions to the current working dir (which
# can happen when deployed).
report <- file.path(getwd(), "pdfReport.Rmd")
#tempReport <- file.path(tempdir(), "pdfReport.Rmd")
#file.copy("pdfReport.Rmd", tempReport, overwrite = TRUE)
params <- list(ilp=updateILP(), ico=updateICO(), sec=updateSecurity(), ppwc=updateWorkPreviousPeriodCompleted(),
pow=updateOngoingWorkCABApproved(), pwcr=updatePlannedWorkCABRequested(), epca=updateEmergencyChangesPendingCABApproval(),
fac=updateFacilities(), drs=updateDRStatus(), ov=updateOperationalEvents(), sl=updateStaffLocations(),
w = updateWeather())
# Knit the document, passing in the `params` list, and eval it in a
# child of the global environment (this isolates the code in the document
# from the code in this app).
rmarkdown::render(report, output_file = file, params = params, envir = new.env(parent = globalenv())
)
}
)
})
Notice, that instead of copying the file to a temp directory, I just specify the file in the current working directory.

ADOQuery on C++ Builder 6 and Windows 7 64bit

I am having a weird problem using the TADOQuery component.
I currently work at a place where they are using Borland C++Builder applications that run on a Windows XP VM. So we want to move to Windows 7 and serve it as a terminal so employees can receive new machines with Windows 10 without the need to create Win XP VM on each machine again.
Currently the application uses BDE components and it works great on XP. We created a Win7 64bit VM for testing, and installed the necessary driver etc, but BDE just won't work. When I try to login through the SQL Explorer that comes with Borland, it just hangs. It sends the request but never gets a response. I spent more than a week trying to debug this issue, but didn't get anywhere with it.
Anyways, I gave up on BDE and wanted to try to change to ADO. So I started by simply creating a TDBGrid and fill it with data using ADO components. It worked great on both XP and Win7! So now I am trying to convert the applications' BDE components (TDataBase, TQuery, etc) to ADO components.
I came across an interesting issue when trying to use parameters. Here is a query example:
SELECT t1.SEC_CODE, t1.CODE, t1.CTRL_NUM, t1.CHECK_CODE,
t1.CHECK_NO, t1.CLIENT_ID, t1.AMOUNT, t1.TRANS_NO, decode(t2.prefix,null,t2.name,t2.name||', '||t2.prefix) as fullName,
t1.ENTRY_DATE, t1.DEPOSIT_DATE, t1.ACCT_COMMENT, t2.NAME, t2.PREFIX
FROM ACCOUNTING.ACCT_CHECK_IN t1, OISC.CLIENT t2
WHERE
(:BEN =1 OR (:BEN =0 AND t1.ENTRY_DATE=:DATE)
OR (:BEN =2 AND t1.DEPOSIT_DATE IS NOT NULL)
OR (:BEN =3 AND t1.DEPOSIT_DATE IS NULL)) AND
(:ALEX =1 OR (:ALEX =0 AND t1.ENTRY_DATE>=:DATE1 AND
t1.ENTRY_DATE<=:DATE2) OR (:ALEX =2 AND t1.DEPOSIT_DATE>=:DATE1
AND t1.DEPOSIT_DATE<=:DATE2))
AND T2.CLIENT_ID(+)=T1.CLIENT_ID
ORDER BY t1.SEC_CODE, t1.CHECK_CODE, fullName, t1.check_no
Please don't pay attention to the parameter names, it's a little funny for me but you guys won't be able to connect.
The first issue here is that even though some parameters are the same name, ADO sees them as individual parameters! So, if I do this:
checkload1->Parameters->ParamByName("BEN")->Value=0
ADO will not replace every occurrence of "BEN" with 0, and I end up with a result set of 0 records! Instead, I am using this:
checkload1->Parameters->Items[0]->Value = 0; // BEN param
checkload1->Parameters->Items[1]->Value = 0;
checkload1->Parameters->Items[3]->Value = 0;
checkload1->Parameters->Items[4]->Value = 0;
Basically, replacing every "BEN" parameter with 0 based on the parameter index.
This brings me results, but not right away.
So here is how it works: the application is a tree based user interface. There is a node that says "Today's Checks" and it displays today's checks when it is expanded. Great, now this works fantastic with BDE, and I only assign the parameter value once and it automatically replaces it wherever it sees "BEN", etc.
When using ADO components, I expand the "Today's Checks" node and the code runs though, loading the parameters, activating the query component and I get no results! So the node stays collapsed. If I click on the + sign again to expand the tree, it loads the checks! And it will load them every time after that.
So, in the application there is a date option that defaults to today's date. If I change that to yesterday's date, I still get today's checks... It's like the parameters aren't getting updated. And if I try to start with a different date at the very beginning, I don't get any results! It will bring results with today's date, but after that it won't accept a different date.
I debugged the code and the dates are changing, but for some reason the parameters aren't changing. Here is my code block:
checkload1->Filter="" ;
checkload1->Filtered=false ;
switch(params)
{
case 0: checkload1->Parameters->Items[0]->Value = 1; // BEN param
checkload1->Parameters->Items[1]->Value = 1;
checkload1->Parameters->Items[3]->Value = 1;
checkload1->Parameters->Items[4]->Value = 1;
// ALEX Param
checkload1->Parameters->Items[5]->Value = 0;
checkload1->Parameters->Items[6]->Value = 0;
checkload1->Parameters->Items[9]->Value = 0;
checkload1->SQL->Strings[13] = "AND t1.CHECK_STATUS NOT IN ('Refunded', 'Posted') ";
break ;
case 1: checkload1->Parameters->Items[0]->Value = 0; // BEN param
checkload1->Parameters->Items[1]->Value = 0;
checkload1->Parameters->Items[3]->Value = 0;
checkload1->Parameters->Items[4]->Value = 0;
checkload1->Parameters->ParamByName("DATE")->Value=FormatDateTime("dd-mmm-yyyy", Date()) ;
checkload1->SQL->Strings[13] = " ";
break ;
case 2: checkload1->Parameters->Items[0]->Value = 2; // BEN param
checkload1->Parameters->Items[1]->Value = 2;
checkload1->Parameters->Items[3]->Value = 2;
checkload1->Parameters->Items[4]->Value = 2;
//ALEX param
checkload1->Parameters->Items[5]->Value = 2;
checkload1->Parameters->Items[6]->Value = 2;
checkload1->Parameters->Items[9]->Value = 2;
checkload1->SQL->Strings[13] = "AND t1.CHECK_STATUS IN ('Deposited') ";
break ;
case 3: checkload1->Parameters->Items[0]->Value = 3; // BEN param
checkload1->Parameters->Items[1]->Value = 3;
checkload1->Parameters->Items[3]->Value = 3;
checkload1->Parameters->Items[4]->Value = 3;
//ALEX param
checkload1->Parameters->Items[5]->Value = 0;
checkload1->Parameters->Items[6]->Value = 0;
checkload1->Parameters->Items[9]->Value = 0;
checkload1->SQL->Strings[13] = "AND t1.CHECK_STATUS IN ('Held') ";
break ;
}
if(!mainform->date1->Checked){
checkload1->Parameters->Items[5]->Value = 1;
checkload1->Parameters->Items[6]->Value = 1;
checkload1->Parameters->Items[9]->Value = 1;
}
checkload1->Parameters->Items[7]->Value = FormatDateTime("dd-mmm-yyyy", fromdate);
checkload1->Parameters->Items[10]->Value = FormatDateTime("dd-mmm-yyyy", fromdate);
checkload1->Parameters->Items[8]->Value = FormatDateTime("dd-mmm-yyyy", todate);
checkload1->Parameters->Items[11]->Value = FormatDateTime("dd-mmm-yyyy", todate);
if(filters != "") checkload1->SQL->Strings[12] = filters;
else checkload1->SQL->Strings[12]=" " ;
checkload1->Prepared = true;
checkload1->Active=true ;
Can someone with experience advise me on this?
I know this is ancient stuff, but those programs were written literally 15-20 years ago, and they are moving to a web-based user interface, but that's still being built. Until then, I need to make the required changes/updates as part of my job.
Okay I got this to work!!
For anyone out there who is struggling with BDE to work on Windows 7 64 bit, here is a solution! Remember the database I am dealing with is Oracle 8i and Borland C++ applications built with C++ Builder 6.
Follow the photo and arrows. I tried to put each photo with its own comment but then this site said I can't post more than 2 links... To hell with them so I put all on one picture.
This TQuery for example is looking for bnetdata as the database. Great, in the next picture we add an ADOConnection component
Click on connection string that's highlighted.
Choose use connection string and click on build.
Select the highlighted provider then click next.
Check use data source name then click the arrow to select one. Note that you will later enter the user name and password and check allow for saving password.
Select the same data source that the BDE components are using. Note that this is one of the sources under your system DSN in the ODBC Administrator. If it's not there, then create one.
Here is a shot from the ODBC Administrator. Note that this is still XP environment. You will need to create the same data source (bnetdata in my case) in the windows 7 machine.
Now click on advanced and check readwrite option from the list.
After you click OK on the ADOConnection component, as you see now in the object inspector. Look at the highlighted areas. Now, we need to set connected property to true. When you do that, it will ask you to log in to the database. Enter the user name and password and click OK. The connection property will now become true. After that you need to set the LoginPrompt property to false. Now click save on the project.
So let's say you have BDE database component too, click on it and then clear alias name and driver name and then put your database name under databaseName property (in my case it's bnetdata).
Save the project and compile in XP. Copy the application and paste it in Windows 7 machine and double click it and it will work! I have successfully converted all the applications to work on Windows 7. The hardest part was to get Borland installed and to get Windows 7 to recognize Oracle ODBC Driver under the Drivers tab in the ODBC Administrator.
Again, SQL Explorer that comes with Borland install is not going to work. So, I will still need to develop in my Windows XP VM but users can use the application in Windows 7 VM served as a terminal on a Windows server... Works for me!!
Hope this helps someone!
EDIT:
I also tried Microsoft OLE DB Provider for Oracle in the ADOConnection and it also worked. Didn't see a measurable impact on speed or performance. Both seem to perform the same way. I'm just surprised how adding the ADOConnection component allowed the application to connect to the database and work like it does in XP!
Also just to clear things up, you will not need to change the BDE components in the application. Only need to add the ADOConnection and all other components stay the same (BDE components). I was trying to convert to using ADO components but there is no need anymore.

SKPaymentQueue addPayment doesn't always trigger native confirm dialog

Ok, I'm implementing IAP into an iOs app and only some products in the store actually trigger the native purchase handling dialogs.
Background:
The app uses cocos2dx with javascript bindings for cross-platformability. We're dipping into the iOs native sectors to implement the store handling.
These calls all work correctly:
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[SKPaymentQueue canMakePayments];
[[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
A note on the last one. All product ids are checked and return as valid in the productsRequest:request didReceiveResponse:response callback but only if I don't include the bundle id in the identifiers that get sent. Most examples I saw said this was needed, but if included they all return as invalidProductIdentifiers. Could this be indicative of a problem?
So currently some products bring up the native purchase confirm dialog after their (previously verified) ids are passed to [[SKPaymentQueue defaultQueue] addPayment:payment]. Most of them simply do nothing afterwards. No callback on paymentQueue:queue updatedTransactions:transactions, no error code, no crash.
I can't see a pattern for why some work and most don't. At least one consumable, non-consumable and subscription work, so I don't think it's that. I found that if I break and step through the code pausing after [[SKPaymentQueue defaultQueue] addPayment:payment], there's a small chance a few products work more often, although it's not consistent. This lead me to think it may be a threading issue, but you can see what I've tried below and it didn't help.
Things I've tried:
Reading around SO and elsewhere, people suggested changing test users, clearing the queue with [[SKPaymentQueue defaultQueue] finishTransaction:transaction], and that Apple's Sandbox server sometimes 'has issues'. But none of this fixed it, and it strikes me as odd that I'm not getting crashes or errors, it just doesn't react at all to certain product ids.
Here's the actual call with some things I've tried:
- (void)purchaseProductWithId:(const char*)item_code
{
/** OCCASIONALLY MAY NEED TO CLEAR THE QUEUE **
NSArray *transactions = [[SKPaymentQueue defaultQueue] transactions];
for(id transaction in transactions){
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
}// */
// dispatch_async(dispatch_get_main_queue(),^ {
SKPayment *payment = [SKPayment paymentWithProductIdentifier:[NSString stringWithUTF8String:item_code]];
// [[SKPaymentQueue defaultQueue] performSelectorOnMainThread:#selector(addPayment:) withObject:payment waitUntilDone:NO];
[[SKPaymentQueue defaultQueue] addPayment:payment];
// } );
}
If there's any other code that could be useful let me know.
Thanks for your help.
Edit:
I've added the hasAddObserver check from this question and that's not the problem either.
Turns out it was a temporary thing. I'd hate to accuse Apple's sandbox servers of being flaky, but nothing was changed and then days later it suddenly worked.
So if you have a similar issue maybe take a break and come back to it later?

mongoDB cursor timeout in C++

I get the following error using mongoDB through its C++ API on a 64-bit installation:
getMore: cursor didn't exist on server, possible restart or timeout?
The code snippet where the error is located is the following:
std::auto_ptr<mongo::DBClientCursor> cursor =
connection.query("database.collection", mongo::BSONObj());
while (cursor->more()) {
// Do stuff
// Update contents of fields
connection.update(...);
}
What the code simply does is updating the contents of each document's fields based on a specific data structure.
The code has been tested with a small data set, and it works perfectly fine, so I assume this is not a coding error, but rather a database-side error that is related to the size of the final data set.
My error looks similar to this bug report. The solution that is proposed there is to set the cursor to have no timeout, but there is no such function for the C++ API, although it seems to exist for other languages.
Any suggestions would be much appreciated.

Maya API: how to change UI Time Working Unit

I need to change the time working unit of Maya using the API.
(see Window->Settings/Preferences->Preferences->Settings->Working Units->Time)
So I do:
MTime::Unit mayaTime = MTime::k120FP;
status = MTime::setUIUnit(mayaTime);
[import some animated data]
// For debug
MTime::Unit tm = MTime::uiUnit();
tm is k120FPS so it is ok. Also, animated data are ok. BUT, when I open the GUI, time working units is still the default one...
The documentation says:
"MTime::setUIUnit: Set the unit system to be used by the user in the UI. After the successful completion of this method, Maya's timeslider will be displaying frames in the specified units."
Do you see what I did wrong here?
Thanks for any help.
Try setting the optionVar "workingUnitTime".