We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Duplicate Plugins Listed
Plugins are duplicated in the authority dropdown.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `lemur/plugins/views.py`
Content:
```
1 """
2 .. module: lemur.plugins.views
3     :platform: Unix
4     :synopsis: This module contains all of the accounts view code.
5     :copyright: (c) 2015 by Netflix Inc., see AUTHORS for more
6     :license: Apache, see LICENSE for more details.
7 .. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
8 """
9 from flask import Blueprint
10 from flask.ext.restful import Api, reqparse, fields
11 from lemur.auth.service import AuthenticatedResource
12 
13 from lemur.common.utils import marshal_items
14 
15 from lemur.plugins.base import plugins
16 
17 mod = Blueprint('plugins', __name__)
18 api = Api(mod)
19 
20 
21 FIELDS = {
22     'title': fields.String,
23     'pluginOptions': fields.Raw(attribute='options'),
24     'description': fields.String,
25     'version': fields.String,
26     'author': fields.String,
27     'authorUrl': fields.String,
28     'type': fields.String,
29     'slug': fields.String,
30 }
31 
32 
33 class PluginsList(AuthenticatedResource):
34     """ Defines the 'plugins' endpoint """
35     def __init__(self):
36         self.reqparse = reqparse.RequestParser()
37         super(PluginsList, self).__init__()
38 
39     @marshal_items(FIELDS)
40     def get(self):
41         """
42         .. http:get:: /plugins
43 
44            The current plugin list
45 
46            **Example request**:
47 
48            .. sourcecode:: http
49 
50               GET /plugins HTTP/1.1
51               Host: example.com
52               Accept: application/json, text/javascript
53 
54            **Example response**:
55 
56            .. sourcecode:: http
57 
58               HTTP/1.1 200 OK
59               Vary: Accept
60               Content-Type: text/javascript
61 
62               {
63                 "items": [
64                     {
65                       "id": 2,
66                       "accountNumber": 222222222,
67                       "label": "account2",
68                       "description": "this is a thing"
69                     },
70                     {
71                       "id": 1,
72                       "accountNumber": 11111111111,
73                       "label": "account1",
74                       "description": "this is a thing"
75                     },
76                   ]
77                 "total": 2
78               }
79 
80            :reqheader Authorization: OAuth token to authenticate
81            :statuscode 200: no error
82         """
83         self.reqparse.add_argument('type', type=str, location='args')
84         args = self.reqparse.parse_args()
85 
86         if args['type']:
87             return list(plugins.all(plugin_type=args['type']))
88 
89         return plugins.all()
90 
91 
92 class Plugins(AuthenticatedResource):
93     """ Defines the the 'plugins' endpoint """
94     def __init__(self):
95         super(Plugins, self).__init__()
96 
97     @marshal_items(FIELDS)
98     def get(self, name):
99         """
100         .. http:get:: /plugins/<name>
101 
102            The current plugin list
103 
104            **Example request**:
105 
106            .. sourcecode:: http
107 
108               GET /plugins HTTP/1.1
109               Host: example.com
110               Accept: application/json, text/javascript
111 
112            **Example response**:
113 
114            .. sourcecode:: http
115 
116               HTTP/1.1 200 OK
117               Vary: Accept
118               Content-Type: text/javascript
119 
120               {
121                   "accountNumber": 222222222,
122                   "label": "account2",
123                   "description": "this is a thing"
124               }
125 
126            :reqheader Authorization: OAuth token to authenticate
127            :statuscode 200: no error
128         """
129         return plugins.get(name)
130 
131 
132 api.add_resource(PluginsList, '/plugins', endpoint='plugins')
133 api.add_resource(Plugins, '/plugins/<name>', endpoint='pluginName')
134
```

Path: `lemur/common/managers.py`
Content:
```
1 """
2 .. module: lemur.common.managers
3     :platform: Unix
4     :copyright: (c) 2015 by Netflix Inc., see AUTHORS for more
5     :license: Apache, see LICENSE for more details.
6 
7 .. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
8 """
9 from flask import current_app
10 
11 
12 # inspired by https://github.com/getsentry/sentry
13 class InstanceManager(object):
14     def __init__(self, class_list=None, instances=True):
15         if class_list is None:
16             class_list = []
17         self.instances = instances
18         self.update(class_list)
19 
20     def get_class_list(self):
21         return self.class_list
22 
23     def add(self, class_path):
24         self.cache = None
25         self.class_list.append(class_path)
26 
27     def remove(self, class_path):
28         self.cache = None
29         self.class_list.remove(class_path)
30 
31     def update(self, class_list):
32         """
33         Updates the class list and wipes the cache.
34         """
35         self.cache = None
36         self.class_list = class_list
37 
38     def all(self):
39         """
40         Returns a list of cached instances.
41         """
42         class_list = list(self.get_class_list())
43         if not class_list:
44             self.cache = []
45             return []
46 
47         if self.cache is not None:
48             return self.cache
49 
50         results = []
51         for cls_path in class_list:
52             module_name, class_name = cls_path.rsplit('.', 1)
53             try:
54                 module = __import__(module_name, {}, {}, class_name)
55                 cls = getattr(module, class_name)
56                 if self.instances:
57                     results.append(cls())
58                 else:
59                     results.append(cls)
60             except Exception:
61                 current_app.logger.exception('Unable to import %s', cls_path)
62                 continue
63         self.cache = results
64 
65         return results
66
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/lemur/common/managers.py b/lemur/common/managers.py
--- a/lemur/common/managers.py
+++ b/lemur/common/managers.py
@@ -22,7 +22,8 @@
 
     def add(self, class_path):
         self.cache = None
-        self.class_list.append(class_path)
+        if class_path not in self.class_list:
+            self.class_list.append(class_path)
 
     def remove(self, class_path):
         self.cache = None
diff --git a/lemur/plugins/views.py b/lemur/plugins/views.py
--- a/lemur/plugins/views.py
+++ b/lemur/plugins/views.py
@@ -86,7 +86,7 @@
         if args['type']:
             return list(plugins.all(plugin_type=args['type']))
 
-        return plugins.all()
+        return list(plugins.all())
 
 
 class Plugins(AuthenticatedResource):

{"golden_diff": "diff --git a/lemur/common/managers.py b/lemur/common/managers.py\n--- a/lemur/common/managers.py\n+++ b/lemur/common/managers.py\n@@ -22,7 +22,8 @@\n \n     def add(self, class_path):\n         self.cache = None\n-        self.class_list.append(class_path)\n+        if class_path not in self.class_list:\n+            self.class_list.append(class_path)\n \n     def remove(self, class_path):\n         self.cache = None\ndiff --git a/lemur/plugins/views.py b/lemur/plugins/views.py\n--- a/lemur/plugins/views.py\n+++ b/lemur/plugins/views.py\n@@ -86,7 +86,7 @@\n         if args['type']:\n             return list(plugins.all(plugin_type=args['type']))\n \n-        return plugins.all()\n+        return list(plugins.all())\n \n \n class Plugins(AuthenticatedResource):\n", "issue": "Duplicate Plugins Listed\nPlugins are duplicated in the authority dropdown.\n\n", "before_files": [{"content": "\"\"\"\n.. module: lemur.plugins.views\n    :platform: Unix\n    :synopsis: This module contains all of the accounts view code.\n    :copyright: (c) 2015 by Netflix Inc., see AUTHORS for more\n    :license: Apache, see LICENSE for more details.\n.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>\n\"\"\"\nfrom flask import Blueprint\nfrom flask.ext.restful import Api, reqparse, fields\nfrom lemur.auth.service import AuthenticatedResource\n\nfrom lemur.common.utils import marshal_items\n\nfrom lemur.plugins.base import plugins\n\nmod = Blueprint('plugins', __name__)\napi = Api(mod)\n\n\nFIELDS = {\n    'title': fields.String,\n    'pluginOptions': fields.Raw(attribute='options'),\n    'description': fields.String,\n    'version': fields.String,\n    'author': fields.String,\n    'authorUrl': fields.String,\n    'type': fields.String,\n    'slug': fields.String,\n}\n\n\nclass PluginsList(AuthenticatedResource):\n    \"\"\" Defines the 'plugins' endpoint \"\"\"\n    def __init__(self):\n        self.reqparse = reqparse.RequestParser()\n        super(PluginsList, self).__init__()\n\n    @marshal_items(FIELDS)\n    def get(self):\n        \"\"\"\n        .. http:get:: /plugins\n\n           The current plugin list\n\n           **Example request**:\n\n           .. sourcecode:: http\n\n              GET /plugins HTTP/1.1\n              Host: example.com\n              Accept: application/json, text/javascript\n\n           **Example response**:\n\n           .. sourcecode:: http\n\n              HTTP/1.1 200 OK\n              Vary: Accept\n              Content-Type: text/javascript\n\n              {\n                \"items\": [\n                    {\n                      \"id\": 2,\n                      \"accountNumber\": 222222222,\n                      \"label\": \"account2\",\n                      \"description\": \"this is a thing\"\n                    },\n                    {\n                      \"id\": 1,\n                      \"accountNumber\": 11111111111,\n                      \"label\": \"account1\",\n                      \"description\": \"this is a thing\"\n                    },\n                  ]\n                \"total\": 2\n              }\n\n           :reqheader Authorization: OAuth token to authenticate\n           :statuscode 200: no error\n        \"\"\"\n        self.reqparse.add_argument('type', type=str, location='args')\n        args = self.reqparse.parse_args()\n\n        if args['type']:\n            return list(plugins.all(plugin_type=args['type']))\n\n        return plugins.all()\n\n\nclass Plugins(AuthenticatedResource):\n    \"\"\" Defines the the 'plugins' endpoint \"\"\"\n    def __init__(self):\n        super(Plugins, self).__init__()\n\n    @marshal_items(FIELDS)\n    def get(self, name):\n        \"\"\"\n        .. http:get:: /plugins/<name>\n\n           The current plugin list\n\n           **Example request**:\n\n           .. sourcecode:: http\n\n              GET /plugins HTTP/1.1\n              Host: example.com\n              Accept: application/json, text/javascript\n\n           **Example response**:\n\n           .. sourcecode:: http\n\n              HTTP/1.1 200 OK\n              Vary: Accept\n              Content-Type: text/javascript\n\n              {\n                  \"accountNumber\": 222222222,\n                  \"label\": \"account2\",\n                  \"description\": \"this is a thing\"\n              }\n\n           :reqheader Authorization: OAuth token to authenticate\n           :statuscode 200: no error\n        \"\"\"\n        return plugins.get(name)\n\n\napi.add_resource(PluginsList, '/plugins', endpoint='plugins')\napi.add_resource(Plugins, '/plugins/<name>', endpoint='pluginName')\n", "path": "lemur/plugins/views.py"}, {"content": "\"\"\"\n.. module: lemur.common.managers\n    :platform: Unix\n    :copyright: (c) 2015 by Netflix Inc., see AUTHORS for more\n    :license: Apache, see LICENSE for more details.\n\n.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>\n\"\"\"\nfrom flask import current_app\n\n\n# inspired by https://github.com/getsentry/sentry\nclass InstanceManager(object):\n    def __init__(self, class_list=None, instances=True):\n        if class_list is None:\n            class_list = []\n        self.instances = instances\n        self.update(class_list)\n\n    def get_class_list(self):\n        return self.class_list\n\n    def add(self, class_path):\n        self.cache = None\n        self.class_list.append(class_path)\n\n    def remove(self, class_path):\n        self.cache = None\n        self.class_list.remove(class_path)\n\n    def update(self, class_list):\n        \"\"\"\n        Updates the class list and wipes the cache.\n        \"\"\"\n        self.cache = None\n        self.class_list = class_list\n\n    def all(self):\n        \"\"\"\n        Returns a list of cached instances.\n        \"\"\"\n        class_list = list(self.get_class_list())\n        if not class_list:\n            self.cache = []\n            return []\n\n        if self.cache is not None:\n            return self.cache\n\n        results = []\n        for cls_path in class_list:\n            module_name, class_name = cls_path.rsplit('.', 1)\n            try:\n                module = __import__(module_name, {}, {}, class_name)\n                cls = getattr(module, class_name)\n                if self.instances:\n                    results.append(cls())\n                else:\n                    results.append(cls)\n            except Exception:\n                current_app.logger.exception('Unable to import %s', cls_path)\n                continue\n        self.cache = results\n\n        return results\n", "path": "lemur/common/managers.py"}], "after_files": [{"content": "\"\"\"\n.. module: lemur.plugins.views\n    :platform: Unix\n    :synopsis: This module contains all of the accounts view code.\n    :copyright: (c) 2015 by Netflix Inc., see AUTHORS for more\n    :license: Apache, see LICENSE for more details.\n.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>\n\"\"\"\nfrom flask import Blueprint\nfrom flask.ext.restful import Api, reqparse, fields\nfrom lemur.auth.service import AuthenticatedResource\n\nfrom lemur.common.utils import marshal_items\n\nfrom lemur.plugins.base import plugins\n\nmod = Blueprint('plugins', __name__)\napi = Api(mod)\n\n\nFIELDS = {\n    'title': fields.String,\n    'pluginOptions': fields.Raw(attribute='options'),\n    'description': fields.String,\n    'version': fields.String,\n    'author': fields.String,\n    'authorUrl': fields.String,\n    'type': fields.String,\n    'slug': fields.String,\n}\n\n\nclass PluginsList(AuthenticatedResource):\n    \"\"\" Defines the 'plugins' endpoint \"\"\"\n    def __init__(self):\n        self.reqparse = reqparse.RequestParser()\n        super(PluginsList, self).__init__()\n\n    @marshal_items(FIELDS)\n    def get(self):\n        \"\"\"\n        .. http:get:: /plugins\n\n           The current plugin list\n\n           **Example request**:\n\n           .. sourcecode:: http\n\n              GET /plugins HTTP/1.1\n              Host: example.com\n              Accept: application/json, text/javascript\n\n           **Example response**:\n\n           .. sourcecode:: http\n\n              HTTP/1.1 200 OK\n              Vary: Accept\n              Content-Type: text/javascript\n\n              {\n                \"items\": [\n                    {\n                      \"id\": 2,\n                      \"accountNumber\": 222222222,\n                      \"label\": \"account2\",\n                      \"description\": \"this is a thing\"\n                    },\n                    {\n                      \"id\": 1,\n                      \"accountNumber\": 11111111111,\n                      \"label\": \"account1\",\n                      \"description\": \"this is a thing\"\n                    },\n                  ]\n                \"total\": 2\n              }\n\n           :reqheader Authorization: OAuth token to authenticate\n           :statuscode 200: no error\n        \"\"\"\n        self.reqparse.add_argument('type', type=str, location='args')\n        args = self.reqparse.parse_args()\n\n        if args['type']:\n            return list(plugins.all(plugin_type=args['type']))\n\n        return list(plugins.all())\n\n\nclass Plugins(AuthenticatedResource):\n    \"\"\" Defines the the 'plugins' endpoint \"\"\"\n    def __init__(self):\n        super(Plugins, self).__init__()\n\n    @marshal_items(FIELDS)\n    def get(self, name):\n        \"\"\"\n        .. http:get:: /plugins/<name>\n\n           The current plugin list\n\n           **Example request**:\n\n           .. sourcecode:: http\n\n              GET /plugins HTTP/1.1\n              Host: example.com\n              Accept: application/json, text/javascript\n\n           **Example response**:\n\n           .. sourcecode:: http\n\n              HTTP/1.1 200 OK\n              Vary: Accept\n              Content-Type: text/javascript\n\n              {\n                  \"accountNumber\": 222222222,\n                  \"label\": \"account2\",\n                  \"description\": \"this is a thing\"\n              }\n\n           :reqheader Authorization: OAuth token to authenticate\n           :statuscode 200: no error\n        \"\"\"\n        return plugins.get(name)\n\n\napi.add_resource(PluginsList, '/plugins', endpoint='plugins')\napi.add_resource(Plugins, '/plugins/<name>', endpoint='pluginName')\n", "path": "lemur/plugins/views.py"}, {"content": "\"\"\"\n.. module: lemur.common.managers\n    :platform: Unix\n    :copyright: (c) 2015 by Netflix Inc., see AUTHORS for more\n    :license: Apache, see LICENSE for more details.\n\n.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>\n\"\"\"\nfrom flask import current_app\n\n\n# inspired by https://github.com/getsentry/sentry\nclass InstanceManager(object):\n    def __init__(self, class_list=None, instances=True):\n        if class_list is None:\n            class_list = []\n        self.instances = instances\n        self.update(class_list)\n\n    def get_class_list(self):\n        return self.class_list\n\n    def add(self, class_path):\n        self.cache = None\n        if class_path not in self.class_list:\n            self.class_list.append(class_path)\n\n    def remove(self, class_path):\n        self.cache = None\n        self.class_list.remove(class_path)\n\n    def update(self, class_list):\n        \"\"\"\n        Updates the class list and wipes the cache.\n        \"\"\"\n        self.cache = None\n        self.class_list = class_list\n\n    def all(self):\n        \"\"\"\n        Returns a list of cached instances.\n        \"\"\"\n        class_list = list(self.get_class_list())\n        if not class_list:\n            self.cache = []\n            return []\n\n        if self.cache is not None:\n            return self.cache\n\n        results = []\n        for cls_path in class_list:\n            module_name, class_name = cls_path.rsplit('.', 1)\n            try:\n                module = __import__(module_name, {}, {}, class_name)\n                cls = getattr(module, class_name)\n                if self.instances:\n                    results.append(cls())\n                else:\n                    results.append(cls)\n            except Exception:\n                current_app.logger.exception('Unable to import %s', cls_path)\n                continue\n        self.cache = results\n\n        return results\n", "path": "lemur/common/managers.py"}]}