I have a shiny UI which allows user to select a date via dateinput box. Given output from this will be backup daily hence would like to use such "date", eg 20181224 as part of filename.
library(shiny)
library(shinyFiles)
ui <- fluidPage(
sidebarPanel(
dateInput("COBInput", "Select a Date", value=Sys.Date())
))
server <- function(input,output,session){
COB <- reactive(as.Date(input$COBInput,format="%Y-%m-%d"))
COB2 <- paste(
"Test",as.character(
format(input$COBInput,format="%Y-%m-%d",'%Y')
)
)}
shinyApp(ui,server)
Error that I got :
Listening on http://127.0.0.1:4973
Warning: Error in .getReactiveEnvironment()$currentContext: Operation not allowed
without an active reactive context. (You tried to do something that can only be
done from inside a reactive expression or observer.)
54: stop
53: .getReactiveEnvironment()$currentContext
52: .subset2(x, "impl")$get
51: $.reactivevalues
47: server [N:/AdHoc Query/R/FFVA/DateInputTest/ShinyApp.R#42]
Error in .getReactiveEnvironment()$currentContext() :
Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)
I would expect for each day, I could save file with name like "Daily20181224","Daily20181221" etc
I was exactly not clear about the requirements but tried using textoutput which can give you idea about how to generate the filename.
library(shiny)
library(shinyFiles)
ui <- fluidPage(
sidebarPanel(
dateInput("COBInput", "Select a Date", value=Sys.Date()),
textOutput("filename")
))
server <- function(input,output,session){
output$filename<-renderText({
input_date<-input$COBInput
year <- as.numeric(format(input_date,'%Y'))
month<-as.numeric(format(input_date,'%m'))
day<-as.numeric(format(input_date,'%d'))
paste0("Daily",year,month,day)
})
}
shinyApp(ui,server)
I think you can generate the filenames now
One thing I like to say about ShinyFiles - I think you are aware that it can only be used for server side file browsing after deployment.
Related
We are receiving fix messages from WebICE exchange in a text file and our application is reading and parsing them line by line using QuickFixJ. We noticed that in some messages the repeating group fields are not being parsed and upon validating with data dictionary getting error.
quickfix.FieldException: Out of order repeating group members, field=326
For example in the sample file data-test.csv the first 2 rows parsed successfully but third one fails with the above error message.
Upon investigation I found , in first 2 rows tag 326 comes after tag 9133 but in the third row it comes before that and hence fails in validation. If I adjust data dictionary as per the third one it succeeds but ofcourse the first one starts failing.
This is happening only for few messages for most of the other fix messages are getting validated and parsed quite fine. This is part of the migration project from existing C# application using QuickFix/N to our scala application using QuickFix/J. And its been working fine at the source end (with QuickFIx/N). Is there any difference in both the libraries QuickFIx/J and QuickFIx/N in terms of dealing with group fields ?
To help recreate the issue , I have shared the data file having 3 fix messages as explained above.
Data file : data-test.csv
Data dictionary : ICE-FIX42.xml
Here is the test code snippet
val dd: DataDictionary = new DataDictionary("ICE-FIX42.xml")
val mfile = new File("data-test.csv")
for (line <- Source.fromFile(mfile).getLines) {
val message = new quickfix.Message(line,dd)
dd.setCheckUnorderedGroupFields(true)
dd.validate(message)
val noOfunderlyings= message.getInt(711)
println("Number of Underlyings "+noOfunderlyings)
for(i <- 1 to noOfunderlyings ) {
val FixGroup: Group = message.getGroup(i, 711)
println("UnderlyingSecurityID : " + FixGroup.getString(311))
}
}
Request to fellow SO users , If you can help me with this.
Many Thanks
You should use setCheckUnorderedGroupFields(false) to disable the validation of the ordering in repeating groups. However, this is only a workaround.
I would suggest to approach your counterparty about this because especially in repeating groups the field order is required to follow the message definition, i.e. the order in the data dictionary.
FIX TagValue encoding spec
Field sequence within a repeating group
...
Fields within repeating groups must be specified in the order that the fields are specified in the message definition.
In a parameterized query issued from c# code to PostgreSQL 10.14 via dotConnect 7.7.832 .NET connector, I select either a parameter value or the local timestamp, if the parameter is NULL:
using (var cmd = new PgSqlCommand("select COALESCE(#eventTime, LOCALTIMESTAMP)", connection)
When executed, this statement throws the error in subject. If I comment out the corresponding parameter
cmd.Parameters.Add("#eventTime", PgSqlType.TimeStamp).Value = DateTime.Now;
and hardcode
using (var cmd = new PgSqlCommand("select COALESCE('11/6/2020 2:36:58 PM', LOCALTIMESTAMP)", connection)
or if I cast the parameter
using (var cmd = new PgSqlCommand("select COALESCE(cast(#eventTime as timestamp without time zone), LOCALTIMESTAMP)", connection)
then it works. Can anyone explain what # operator in the error is referring to and why the error?
In the case that doesn't work, your .Net connection library seems to be passing an SQL command containing a literal # to the database, rather than substituting it. The database assumes you are trying to use # as a user defined operator, as it doesn't know what else it could possibly be. But no such operator has been defined.
Why is it doing that? I have no idea. That is a question about your .Net connection library, not about PostgreSQL itself, so you might want to add tag.
The error message you get from the database should include the text of the query it received (as opposed to the text you think it was sent) and it is often useful to see that in situations like this. If that text is not present in the client's error message (some connection libraries do not faithfully pass this info along) you should be able to pull it directly from the PostgreSQL server's log file.
I apologize if this is too vague a question, but we're having the following problem:
We use a search form to find a record, then load it in a bound-control form where changes are made. Then we return to the search form and open another record. When we do that, the form's BeforeUpdate property fires a 3020 error, "Update without Add New or Edit" and stepping through the code it's referring to the FIRST opened record. This is strange because there is no explicit update call, but after much trial and error I think the error is thus:
Record #1 is opened via the form and changes are made. Record #2 is opened on that same form without closing the first recordset. Even though we now re-opened the form with the second record, Access still assumes we're editing record 1, i.e. that we're trying to edit 2 records concurrently. Same as though we had a datasheet form and we edited one row and then tried to edit a second row without saving the first. What I want to be able to do is have it automatically do an update on the first record when the form deactivates so loading a new record doesn't cause this conflict.
So the bottom line is this: **Is there a way, on say the form's Dirty or Deactivate event, that we can force the form's recordset to update and close ** before loading a second record?
I hope I made this clear enough, it's a complex problem, so any small guidance would help. Btw, you may ask, "Why are you running the same code to open the same form twice?" Good question! Hey it's an old and badly written app (the thing has GoSubs in it for Pete's sake) but I have no choice but to make the best of a bad situation.
EDIT: I was asked to post code, which is reasonable, but it's in several different places. So I have the data form, it has a "Search" button to go back to the search form for opening another record. The search button on the data entry form is:
Private Sub CommandSearch_Click()
On Error GoTo Err_CommandSearch_Click
DoCmd.OpenForm "Reference Form", acNormal 'This is the form that does the searching
Exit_CommandSearch_Click:
Exit Sub
Err_CommandSearch_Click:
MsgBox Err.Description
Resume Exit_CommandSearch_Click
End Sub
When a record is selected on that search form, then the new form is opened with this code. Now this is where it gets tricky. I'm not the original programmer, as I said I think it was written in Access 97 by someone after taking an hour to read "Access for Dummies" :). But it always looks like only one copy of the form is open, so maybe it's re-opening it?
Public Sub CommandLoadCase_Click()
Dim LoadUTUCaseNumber As String, lengthUTUCaseNumber As Integer
lengthUTUCaseNumber = InStr(Forms![Reference Form]![Reference Query SubForm]![UTU Case Number], "-") - 1
If (lengthUTUCaseNumber = 0) Then
LoadUTUCaseNumber = ""
Else
LoadUTUCaseNumber = Left$(Forms![Reference Form]![Reference Query SubForm]![UTU Case Number], lengthUTUCaseNumber)
End If
On Error Resume Next
Forms![Case Appeal_Add-On Form].UTUCaseKeyToFind = LoadUTUCaseNumber
DoCmd.OpenForm "Case Appeal_Add-On Form", acNormal, , , , , LoadUTUCaseNumber
'Case Appeal Add On Form referred to here is the data entry form I refer to above.
End Sub
Finally, the Error 3020 (Update without Add/Edit) is occurring after it executes this line on the data entry form. (I know the code is complicated which is why I didn't enter it at first).
Private Sub Form_BeforeUpdate(Cancel As Integer)
[UTU Claim Sequence Key] = [UTU Claim Alpha Sequence] & CStr([UTU Claim Numeric Sequence])
End Sub
I'm scraping publicly available data for academic research. The website I'm pulling the information from has a really annoying datepicker though. I'm not sure if they implement this to deter private companies from scraping criminal data but it seems pretty dumb.
Here's the url.
I can bypass the Captcha with my institutional credentials, FYI.
You can see code - minus the login information - below:
#Miami Scraper
rm(list=ls())
remDr$close()
rm(rD)
gc()
rm(list=ls())
setwd("~/Desktop/Miami Scrape")
library(httr)
library(rvest)
library(zoo)
library(anytime)
library(lubridate)
library(dplyr)
library(RSelenium)
browser <- remoteDriver(port = 5556, browserName = "firefox")
remDr<-browser[["client"]]
url <- "https://www2.miami-dadeclerk.com/PremierServices/login.aspx"
rD <- rsDriver(verbose=FALSE,port=4444L,browser="firefox")
remDr <- rD$client
remDr$navigate(url)
#Click the Logging In Option
#Log-in stuff happens here
url2 <- "https://www2.miami-dadeclerk.com/cjis/casesearch.aspx"
remDr <- rD$client
remDr$navigate(url2)
#Here, you will read in the sheets. Let's start with a handful
date <- c("02", "01", "01")
sequence <- c("030686","027910","014707")
seqbar <- remDr$findElement("id","txtCaseNo3")
seqbar$sendKeysToElement(list(sequence[1]))
type <- remDr$findElement("id","ddCaseType")
type$clickElement()
type$sendKeysToElement(list("F","\n"))
yearbar <- remDr$findElement("id","txtCaseNo2")
yearbar$clearElement()
prev <- remDr$setTimeout("2000")
yearbar$sendKeysToElement(list(date[1]))
Invariably, the datepicker defaults to 19 but this isn't systematic. I'm only beginning to develop the code but I notice if I use the same case information for two searches in a row that it'll switch from "02" to "19" regularly. If I switch to another case, it may not work either. I'm not sure how to deal with this datepicker. Any help would be greatly appreciated.
I've tried a couple of things. As you can see, I've tried to clear out the default and slow my code, too. That doesn't seem to work.
Also one last note, if you line-by-line run the code it works but execution all at once won't run properly.
I can't test with R as can't seem to get RSelenium set up, but changing the value attribute of the year input box seems to work. In R it looks like there are two ways to do that.
Can't test, but something like:
year <- '02'
#method 1 using inbuilt method which executes js under hood
remDr$findElement('id','txtCaseNo2')$setElementAttribute('value',year)
#method 2 js direct
js <- paste0("document.querySelector('#txtCaseNo2').value='", year,"';")
remDr$executeScript(js)
Anyway, might be enough to get you on track for a solution.
I tested similar versions with Python successfully
from selenium import webdriver
d = webdriver.Chrome()
d.get('https://www2.miami-dadeclerk.com/cjis/casesearch.aspx?AspxAutoDetectCookieSupport=1')
case_nums = ["030686"]
year = '02'
d.execute_script("document.querySelector('#txtCaseNo2').value='" + year + "';")
# d.execute_script("arguments[0].value = '02';", d.find_element_by_id('txtCaseNo2'))
d.find_element_by_id('txtCaseNo3').send_keys(case_nums[0])
d.find_element_by_css_selector('[value=F]').click()
captcha = input()
d.find_element_by_id('CaptchaCodeTextBox').send_keys(captcha)
d.find_element_by_id('btnCaseSearch').click()
I've been trying to append some more data to an OTRS ticket (newest version). And I have managed to get the information in the ticket data alright, however, I do not know how to access it in the view. Most data seems to be parsed through via $QData/$Data, however, all I get when I print my variable is 16/12.
%CustomerCompanyName = $Self->{CustomerCompanyObject}->CustomerCompanyGet( CustomerID => $Ticket{CustomerID} );
#}
$Ticket{CustomerCompanyName} = \%CustomerCompanyName;
And I want to access it in the dtl AgentDashboardTicketGeneric.dtl, however, $Data{"CustomerCompanyName"} is empty. I've managed to get the hash or 16/12 out. Again, in the variable $Ticket we've managed to dump the variable and see the data is actually in there (without actually being able to access it, we can't figure out which data type it is and have tried all possible ways we could think of).
Edit: I figured it out. It worked with Johannes solution, however, the value of the column in the SysConfig had to be 2, and not 1.
you can access all Ticket Data through the User Interface. In every widget, in the top right corner you can access the settings and remove, add, sort columns.
If you need the Customer Company data, which are not bound to the ticket-data, then you need to modify / extend the given module (Kernel::Output::HTML::DashboardTicketGeneric). Thats the reason why $Data{"CustomerCompanyName"} is empty, because the customer company stuff is not loaded there.
IMHO you don't need to modify the dtl. Add the new column in the sysconfig:
HTTP://OTRSHOST/otrs/index.pl?Action=AdminSysConfig;Subaction=Edit;SysConfigSubGroup=Frontend%3A%3AAgent%3A%3ADashboard;SysConfigGroup=Ticket
Add the new Column "CompanyName" to every widgets DefaultColumns.
(Hint: here you can also add DynamicFields using DynamicField_XXX)
Then modify the Code in DashboardTicketGeneric.pm
First: add the module (around L:21)
use Kernel::System::CustomerCompany;
after that initiate the module (after CustomerUserObject around L: 44)
$Self->{CustomerCompanyObject} = Kernel::System::CustomerCompany->new(%Param);
Then add the logic to the module (around L: 1414 - after the customer name block:
elsif ( $Column eq 'CompanyName' ) {
# get customer company name
my %CompanyData;
if ( $Ticket{CustomerID} ) {
%CompanyData = $Self->{CustomerCompanyObject}->CustomerCompanyGet(
CustomerID => $Ticket{CustomerID},
);
}
$DataValue = $CompanyData{CustomerCompanyName};
}
Then delete the cache (..bin/otrs.DeleteCache.pl), because widgets use caching and your changes won't apply fast enough ;)
Add the column to your widget (top right corner in the widget -> Settings) and you should be fine.
Update: place the "new Module" in the custom folder
Custom/Kernel/Output/HTML/DashboardTicketGeneric.pm
regards
Johannes