Repository: Miserlou/Zappa

Issue:
Error keeping warm
(Pressed enter by error)

```
[1476748267924] Zappa Event: ...zappa-keep-warm-handl.keep_warm_callback...
[1476748267924] No module named handl: ImportError
Traceback (most recent call last):
  File "/var/task/handler.py", line 476, in lambda_handler
    return LambdaHandler.lambda_handler(event, context)
  File "/var/task/handler.py", line 208, in lambda_handler
    raise ex
ImportError: No module named handl
```

Zappa version: 0.27.1



Discussion:
Whats the error

From my phone..

On Oct 17, 2016 7:52 PM, "Fernando Mumbach" notifications@github.com
wrote:

> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> https://github.com/Miserlou/Zappa/issues/403, or mute the thread
> https://github.com/notifications/unsubscribe-auth/AAIi01103rzDqchyvdwbCVZZSu96-ZXbks5q1ApVgaJpZM4KZO5Z
> .

I pressed enter instead of tab so I created the issue without a description. Sorry. I edited the content already.

What's your Zappa version?

Is your project_name/`pwd` quite long?

_Zappa version:_ 0.27.1

My project name is quite large, yeah. It's 26 characters. Is that a problem? What's the limit?

Yeah, it's supposed to truncate at it, but it looks like it's doing it
wrong. Try setting `project_name` to something smaller?

On Mon, Oct 17, 2016 at 9:13 PM, Fernando Mumbach notifications@github.com
wrote:

> _Zappa version:_ 0.27.1
> 
> My project name is quite large, yeah. It's 26 characters. Is that a
> problem? What's the limit?
> 
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> https://github.com/Miserlou/Zappa/issues/403#issuecomment-254379576, or mute
> the thread
> https://github.com/notifications/unsubscribe-auth/AAIi0wWty_jew_LcIeMhPF9Ydf0rlVq6ks5q1B1MgaJpZM4KZO5Z
> .

Changed the project name to 15 characters long. Before this problem it was 17 characters long.
Ran `zappa update` and still having the same error.
Do I need to redeploy?


Resolving patch:
diff --git a/zappa/zappa.py b/zappa/zappa.py
--- a/zappa/zappa.py
+++ b/zappa/zappa.py
@@ -1691,17 +1691,7 @@ def get_event_name(lambda_name, name):
         Returns an AWS-valid Lambda event name.
 
         """
-        event_name = '{}-{}'.format(lambda_name, name)
-        if len(event_name) > 64:
-            if '.' in event_name: # leave the function name, but re-label to trim
-                name, function = event_name.split('.', 1)
-                function = "." + function
-                name_len = len(function)
-                name = name[:(64-len(function))]
-                event_name = name + function
-            else:
-                event_name = event_name[:64]
-        return event_name
+        return '{prefix:.{width}}-{postfix}'.format(prefix=lambda_name, width=max(0, 63 - len(name)), postfix=name)[:64]
 
     def delete_rule(self, rule_name):
         """


Test patch:
diff --git a/tests/tests.py b/tests/tests.py
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -967,10 +967,12 @@ def test_event_name(self):
         zappa = Zappa()
         truncated = zappa.get_event_name("basldfkjalsdkfjalsdkfjaslkdfjalsdkfjadlsfkjasdlfkjasdlfkjasdflkjasdf-asdfasdfasdfasdfasdf", "this.is.my.dang.function.wassup.yeah.its.long")
         self.assertTrue(len(truncated) <= 64)
+        self.assertTrue(truncated.endswith("this.is.my.dang.function.wassup.yeah.its.long"))
         truncated = zappa.get_event_name("basldfkjalsdkfjalsdkfjaslkdfjalsdkfjadlsfkjasdlfkjasdlfkjasdflkjasdf-asdfasdfasdfasdfasdf", "thisidoasdfaljksdfalskdjfalsdkfjasldkfjalsdkfjalsdkfjalsdfkjalasdfasdfasdfasdklfjasldkfjalsdkjfaslkdfjasldkfjasdflkjdasfskdj")
         self.assertTrue(len(truncated) <= 64)
         truncated = zappa.get_event_name("a", "b")
         self.assertTrue(len(truncated) <= 64)
+        self.assertEqual(truncated, "a-b")
 
     def test_detect_dj(self):
         # Sanity