Having some issue when applying my terraform plan, and cannot pinpoint what is the problem in it. I tried everything I could think about. Here is my lambda.tf file:
data "archive_file" "projectLeo_listunsubscribe_lambda_code" {
type = "zip"
source_dir = "${path.module}/../src/ProjectLeo.ListUnsubscribe"
output_path = "${path.module}/../src/code-packaged/list-unsubscribe.zip"
}
resource "aws_lambda_function" "projectLeot_list_unsubscribe_lambda" {
filename = "${data.archive_file.projectLeo_listunsubscribe_lambda_code.output_path}"
function_name = "projectLeo-listunsubscribe-lambda"
role = "${aws_iam_role.projectLeo_list_hygiene_role.arn}"
handler = "${var.lambda_list_unsubscribe_function_handler}"
runtime = "dotnetcore2.1"
memory_size = "256"
timeout = 120
publish = true
reserved_concurrent_executions = 1
environment {
variables = {
optout-topic-arn = "${data.aws_sns_topic.projectLeo_optout_topic.arn}"
}
}
}
data "aws_sns_topic" "projectLeo_optout_topic" {
name = "${var.sns_optout_topic_name}"
}
The plan generated looks all fine, ut this error is generated when apply is done:
Error: Error creating Lambda function: ValidationException:
status code: 400, request id: c16dc369-bccd-418d-a2b5-2d0383c66064
on ..\list-unsubscribe\infrastructure\lambda.tf line 9, in resource "aws_lambda_function" "projectLeo_list_unsubscribe_lambda":
9: resource "aws_lambda_function" "projectLeo_list_unsubscribe_lambda" {
That's quite a light log to work with, I tried updating pieces by pieces of the code but always have the same result.
Can anybody help me pinpoint what may be the issue with my code? Thanks!
Finally manage to identify the issue: the environment variables in AWS lambda function doesn't accept hyphen (-). I replaced it by underscore and it went through.
optout-topic-arn became optout_topic_arn
Related
Before anyone points it out, yes, I know there have been similar questions asked before. I've already tried solutions from them and they do not work, which is why I'm asking this question.
For reference, I'm using Android API 30.
So I'm performing a query on all audio files on the device using MediaStore. As of now I'm able to properly access artist/album/song IDs, names, etc. and use them elsewhere in my app. The one thing I'm unable to get though is the album art.
This is what my code looks like:
string[] columns = {
MediaStore.Audio.Media.InterfaceConsts.IsMusic,
MediaStore.Audio.Media.InterfaceConsts.Data,
MediaStore.Audio.Media.InterfaceConsts.Title,
MediaStore.Audio.Media.InterfaceConsts.CdTrackNumber,
MediaStore.Audio.Media.InterfaceConsts.Duration,
MediaStore.Audio.Media.InterfaceConsts.Id,
MediaStore.Audio.Media.InterfaceConsts.Album,
MediaStore.Audio.Media.InterfaceConsts.AlbumId,
MediaStore.Audio.Media.InterfaceConsts.Artist,
MediaStore.Audio.Media.InterfaceConsts.ArtistId,
};
ICursor? cursor = context.ContentResolver?.Query(MediaStore.Audio.Media.ExternalContentUri!, columns, null, null, null);
if (cursor is null)
{
return;
}
while (cursor.MoveToNext())
{
if (cursor.GetString(0) is not "1")
{
continue;
}
string trackPath = cursor.GetString(1)!;
string trackTitle = cursor.GetString(2)!;
int trackIndex = cursor.GetInt(3);
uint trackDuration = (uint)(cursor.GetFloat(4) / 1000);
long trackId = cursor.GetLong(5);
string albumTitle = cursor.GetString(6)!;
long albumId = cursor.GetLong(7);
string artistName = cursor.GetString(8)!;
long artistId = cursor.GetLong(9);
I initially tried the obvious method, which was adding MediaStore.Audio.Media.InterfaceConsts.AlbumArt to columns and getting the data from that column. But just adding that causes the application to freeze. Logging shows that adding it causes the method to freeze midway and not do anything. So this solution is out.
I then tried MediaMetadataRetriever, like this:
MediaMetadataRetriever retriever = new();
retriever.SetDataSource(trackPath);
byte[] artwork = retriever.GetEmbeddedPicture()!;
Bitmap albumArt = BitmapFactory.DecodeByteArray(artwork, 0, artwork.Length)!;
However, this also fails. I get an error message in the logs saying that MediaMetadataRetriever was unable to set the data source to that source.
So I figured maybe my data source was wrong. After doing some digging around I tried using a different path:
Uri contentUri = Uri.Parse("content://media/external/audio/albumart")!;
Uri albumArtUri = ContentUris.WithAppendedId(contentUri, albumId);
MediaMetadataRetriever retriever = new();
retriever.SetDataSource(albumArtUri.Path);
...
This also does not work. Neither does using MediaStore.Audio.Albums.ExternalContentUri.
I even tried opening a ParcelFileDescriptor from those URIs. Also doesn't work.
Does anyone know of a way that would definitely work? Most of the answers on StackOverflow seem to be quite dated, so they possibly don't apply to API 30 anymore. But I don't know what I'm doing wrong since the documentation isn't very detailed.
I have this control (db is the Entity Framework context):
if (db.Sites.Any(s => s.Name.Equals(name))) throw new NameAlreadyInUseException(name);
When I run my tests and debug it fails giving me the error:
Error CS0103: the name 's' does not exist in the current context.
I honestly can't get my head around it and Google hasn't really been helping... any help is appreciated, thanks in advance. Isn't s used correctly here? (I'm still learning, so maybe I missed something but my code here looks ok to me)
Edit:
the debugger triggers the error on this line and I am not using s in any other place other than inside that if statement. (I edited the line to show what happens with the if)
Edit2: complete code of the function
public void CreateSiteOnDb(string connectionString, string name, int timezone, int sessionExpirationTimeInSeconds,
double minimumBidIncrement)
{
CheckInput_CreateSiteOnDb(connectionString, name, timezone, sessionExpirationTimeInSeconds, minimumBidIncrement);
try
{
using (var db = new AuctionSiteContext(connectionString))
{
if (db.Sites.Any(s => s.Name.Equals(name))) throw new NameAlreadyInUseException(name);
var site = new Entities.Site
{
Name = name,
Timezone = timezone,
MinimumIncrement = minimumBidIncrement,
SessionExpirationInSeconds = sessionExpirationTimeInSeconds
};
db.Sites.Add(site);
db.SaveChanges();
}
}
catch(NameAlreadyInUseException)
{
throw;
}
catch(Exception)
{
throw new UnavailableDbException();
}
}
Edit3: Error as shown during debugging
It is not in the right scope.
In the screenshot you are in the scope of CreateSiteOnDb -> try -> using, but s does not belong to that context.
In very basic terms s => .... is converted to function of a class, and it is called from inside Any. so let's assume that our expression is function named Steve. Steve would look like this:
bool Steve(ISite s)
{
return s.Name.Equals(name);
}
this means s is the parameter of Steve, and is only valid inside Steve, which becomes CreateSiteOnDb -> try -> using -> Any -> Steve
So to see s you need to be in two more levels. Please, put your cursor inside the expression and then put a breakpoint.
So I'm building an app with twilio voice, and I've got all the phonecall stuff working. But I'm having a little trouble understanding which parameters my callback should have.
I've registered the URL as described in the docs:
options.From = formatPhoneNumber(callout.callback_number);
options.To = formatPhoneNumber(offer.employee_phone_number);
options.Url = TwilioCallBotController.TwilioCalloutScriptURL;
options.StatusCallback = TwilioCallBotController.StatusCallbackURL;
options.StatusCallbackEvents = new []{"initiated", "ringing", "answered", "completed" };
options.StatusCallbackMethod = "POST";
I've also made a callback method here, but I'm not having much luck finding out how the parameters are supposed to work with their API. I'm kindof at a loss as to what could be the reason behind this one not working:
[HttpPost]
public ActionResult TwilioStatusCallback()
{
var twiml = new Twilio.TwiML.TwilioResponse();
twiml.Say("This is a test");
string CallSid = Request.Form["CallSid"];
string CallStatus = Request.Form["CallStatus"];
Debug.WriteLine("Status Callback Delivered");
Shift_Offer shoffer = db.Shift_Offers.Where(s => s.twillio_sid == CallSid).ToList()[0];
shoffer.status = CallStatus.ToString();// + DateTime.Now.ToString();
return TwiML(twiml);
}
Edit:
So it turns out that the API is very sensitive about the method signature (the call was previously throwing a method not found exception in a number of microsoft DLLs, including System.Web and System.Web.Mvc.
So I've actually gotten the software to call the method by using an empty method signature (no parameters).
However I'm still having trouble getting the parameters from the HTTPPOST
Edit: So upon further investigation I've managed to inspect the Request. The values I'm after exist in Request.Form["foo"], but they don't seem to be getting put into the two strings I have declared. I've removed the ["HttpPost"] attribute to try to troubleshoot the issue, but I'm really at a loss as to why I can see the values in the debugger, but they're not translating into memory.
public ActionResult TwilioStatusCallback()
{
var twiml = new Twilio.TwiML.TwilioResponse();
string sid = Request.Form["CallSid"];
string status = Request.Form["CallStatus"];
Shift_Offer shoffer = db.Shift_Offers.Where(s => s.twillio_sid == sid).ToList()[0];
shoffer.status = status;// + DateTime.Now.ToString();
return TwiML(twiml);
}
Last issue was that the database wasn't being saved.
Just added a db.SaveChanges() and we're good.
I have all the necessary requirements when using the R.NET from http://rdotnet.codeplex.com/
My code works just fine on R Studio, however no luck on GUI. Can anybody let me know what I am doing wrong please?
REngine.SetEnvironmentVariables(#"C:\Program Files\R\R-3.1.1\bin\i386", #"C:\Program Files\R\R-3.1.1");
engine = REngine.GetInstance();
engine.Evaluate(#"source('C:/Users/achugh/Documents/Graphs/characterization.r')");
engine.Evaluate(#"source('C:/Users/achugh/Documents/Graphs/sliderDataToComputer.r')");
var sliderfunc = engine.Evaluate("sliderdata_yprofile").AsFunction();
var directory = engine.CreateCharacterVector(new[] { "C:/Users/achugh/Documents/Graphs/data" });
var oldset = sliderfunc.Invoke(new SymbolicExpression[] { directory }).AsDataFrame();
But for some reason the 'oldset' always evaluates to NULL. I already tried testing this via R-Studio
please advice?
Are you absolutely sure your function returns a data frame and not a matrix? The following behaves exactly as expected, and as you describe. I am working from the latest code but this part of R.NET is identical to the latest 1.5.16. Please mark this post as an answer if indeed correct, just not to confuse readers as to the behavior of R data coercion.
var funcDef = #"function(lyrics) {return(data.frame(a=1:4, b=5:8))}";
var f = engine.Evaluate(funcDef).AsFunction();
var x = f.Invoke(engine.CreateCharacter("Wo willst du hin?"));
Assert.True(x.IsDataFrame());
Assert.True(x.IsList());
var df = x.AsDataFrame();
Assert.NotNull(df);
funcDef = #"function() {return(as.matrix(data.frame(a=1:4, b=5:8)))}";
f = engine.Evaluate(funcDef).AsFunction();
x = f.Invoke();
Assert.False(x.IsDataFrame());
Assert.False(x.IsList());
df = x.AsDataFrame();
Assert.Null(df);
var nm = x.AsNumericMatrix();
Assert.NotNull(nm);
Answer:
var oldset = sliderfunc.Invoke(new SymbolicExpression[] { directory }).AsDataFrame();
change the above line to :
var oldset = sliderfunc.Invoke(new SymbolicExpression[] { directory }).AsNumericMatrix();
The reason are unknown, although the script is returning a data frame , but it fails to recognize this as data frame but recognizes this as Numeric Matrix.
EDIT: I forgot to mention this is working with an axis encoder.
I've recently started using gStreamer-sharp and I can get a video playing with playbin but I need my video to be live, thus a need to set the latency. but I have come across this error:
GST_ELEMENT_PADS gstelement.c:722:gst_element_add_pad:<Source> adding pad 'recv_rtp_src_0_219678342_96'
0:00:11.033000000 13088 05418DA0 INFO basesrc gstbasesrc.c:2519:gst_base_src_loop:<udpsrc1> pausing after gst_pad_push() = not-linked
0:00:11.033000000 13088 05418DA0 WARN basesrc gstbasesrc.c:2582:gst_base_src_loop:<udpsrc1> error: Internal data flow error.
0:00:11.033000000 13088 05418DA0 WARN basesrc gstbasesrc.c:2582:gst_base_src_loop:<udpsrc1> error: streaming task paused, reason not-linked (-1)
0:00:11.214000000 13088 05418DA0 INFO GST_ERROR_SYSTEM gstelement.c:1931:gst_element_message_full:<udpsrc1> posting message: Internal data flow error.
0:00:11.214000000 13088 05418DA0 INFO GST_ERROR_SYSTEM gstelement.c:1954:gst_element_message_full:<udpsrc1> posted error message: Internal data flow error.
Which has lead me to believe it's a problem with the pad's my code is as following:
Gst.Video.VideoSink videoSink;
Pipeline m_Pipeline;
Element m_Source, m_Demux, m_Decoder, m_Space;
private void OnVideoPadAdded(object sender, Gst.PadAddedArgs args)
{
Gst.Element.Link(m_Demux, m_Decoder);
}
private void CreatePipeline()
{
m_Pipeline = new Pipeline("video player");
m_Source = Gst.ElementFactory.Make("rtspsrc", "Source");
m_Source["location"] = #"rtsp://root:root#192.168.8.159:554/axis-media/media.3gp";
m_Demux = Gst.ElementFactory.Make("rtph264depay", "Depay");
m_Decoder = Gst.ElementFactory.Make("ffdec_h264", "Decoder");
m_Space = ElementFactory.Make("ffmpegcolorspace", "Space");
videoSink = Gst.ElementFactory.Make("directdrawsink", "Output") as Gst.Video.VideoSink;
videoSink["force-aspect-ratio"] = true;
m_Pipeline.Add(m_Source, m_Demux, m_Decoder, m_Space, videoSink);
m_Pipeline.SetState(Gst.State.Ready);
m_Source.Link(m_Demux);
m_Demux.PadAdded += new Gst.PadAddedHandler(OnVideoPadAdded);
m_Decoder.Link(m_Space);
m_Space.Link(videoSink);
var overlay = new Gst.Interfaces.XOverlayAdapter(videoSink.Handle);
overlay.XwindowId = (ulong)videoPanel.Handle;
m_Pipeline.SetState(Gst.State.Paused);
m_Pipeline.SetState(State.Playing);
}
Any help is appreciated.
Solution was pretty simple in the end.
Needed to add the handler:
m_Source.PadAdded += new Gst.PadAddedHandler(OnVideoPadAdded);
then handle the sink correctly by getting the static pad in the handler:
Pad sinkpad = m_Demux.GetStaticPad("sink");
args.Pad.Link(sinkpad);