We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Setting "Custom code" in StaticComponent doesn't seem to have any effect
The generated script doesn't contain any traces of the `Custom code` entered in the `StaticComponent`'s properties dialog.

`psychopy:master`

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `psychopy/experiment/components/static/__init__.py`
Content:
```
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 """
5 Part of the PsychoPy library
6 Copyright (C) 2018 Jonathan Peirce
7 Distributed under the terms of the GNU General Public License (GPL).
8 """
9 
10 from __future__ import absolute_import, print_function
11 
12 from builtins import str
13 from os import path
14 from psychopy.experiment.components import BaseComponent, Param, _translate
15 
16 __author__ = 'Jon Peirce'
17 
18 # the absolute path to the folder containing this path
19 thisFolder = path.abspath(path.dirname(__file__))
20 iconFile = path.join(thisFolder, 'static.png')
21 tooltip = _translate('Static: Static screen period (e.g. an ISI). '
22                      'Useful for pre-loading stimuli.')
23 _localized = {'Custom code': _translate('Custom code')}
24 
25 
26 class StaticComponent(BaseComponent):
27     """A Static Component, allowing frame rendering to pause.
28 
29     E.g., pause while disk is accessed for loading an image
30     """
31     # override the categories property below
32     # an attribute of the class, determines the section in the components panel
33     categories = ['Custom']
34 
35     def __init__(self, exp, parentName, name='ISI',
36                  startType='time (s)', startVal=0.0,
37                  stopType='duration (s)', stopVal=0.5,
38                  startEstim='', durationEstim=''):
39         BaseComponent.__init__(self, exp, parentName, name=name)
40         self.updatesList = []  # a list of dicts {compParams, fieldName}
41         self.type = 'Static'
42         self.url = "http://www.psychopy.org/builder/components/static.html"
43         hnt = _translate(
44             "Custom code to be run during the static period (after updates)")
45         self.params['code'] = Param("", valType='code',
46                                     hint=hnt,
47                                     label=_localized['Custom code'])
48         self.order = ['name']  # make name come first (others don't matter)
49 
50         hnt = _translate("How do you want to define your start point?")
51         self.params['startType'] = Param(startType, valType='str',
52                                          allowedVals=['time (s)', 'frame N'],
53                                          hint=hnt)
54         hnt = _translate("How do you want to define your end point?")
55         _allow = ['duration (s)', 'duration (frames)', 'time (s)', 'frame N']
56         self.params['stopType'] = Param(stopType, valType='str',
57                                         allowedVals=_allow,  # copy not needed
58                                         hint=hnt)
59         hnt = _translate("When does the component start?")
60         self.params['startVal'] = Param(startVal, valType='code',
61                                         allowedTypes=[],
62                                         hint=hnt)
63         hnt = _translate("When does the component end? (blank is endless)")
64         self.params['stopVal'] = Param(stopVal, valType='code',
65                                        allowedTypes=[],
66                                        updates='constant', allowedUpdates=[],
67                                        hint=hnt)
68         hnt = _translate("(Optional) expected start (s), purely for "
69                          "representing in the timeline")
70         self.params['startEstim'] = Param(startEstim, valType='code',
71                                           allowedTypes=[],
72                                           hint=hnt)
73         hnt = _translate("(Optional) expected duration (s), purely for "
74                          "representing in the timeline")
75         self.params['durationEstim'] = Param(durationEstim, valType='code',
76                                              allowedTypes=[],
77                                              hint=hnt)
78 
79     def addComponentUpdate(self, routine, compName, fieldName):
80         self.updatesList.append({'compName': compName,
81                                  'fieldName': fieldName,
82                                  'routine': routine})
83 
84     def remComponentUpdate(self, routine, compName, fieldName):
85         # have to do this in a loop rather than a simple remove
86         target = {'compName': compName, 'fieldName': fieldName,
87                   'routine': routine}
88         for item in self.updatesList:
89             if item == target:
90                 self.updatesList.remove(item)
91 
92     def writeInitCode(self, buff):
93         code = ("%(name)s = clock.StaticPeriod(win=win, "
94                 "screenHz=expInfo['frameRate'], name='%(name)s')\n")
95         buff.writeIndented(code % self.params)
96 
97     def writeFrameCode(self, buff):
98         self.writeStartTestCode(buff)
99         # to get out of the if statement
100         buff.setIndentLevel(-1, relative=True)
101         self.writeStopTestCode(buff)
102 
103     def writeStartTestCode(self, buff):
104         """This will be executed as the final component in the routine
105         """
106         buff.writeIndented("# *%s* period\n" % (self.params['name']))
107         BaseComponent.writeStartTestCode(self, buff)
108 
109         if self.params['stopType'].val == 'time (s)':
110             durationSecsStr = "%(stopVal)s-t" % (self.params)
111         elif self.params['stopType'].val == 'duration (s)':
112             durationSecsStr = "%(stopVal)s" % (self.params)
113         elif self.params['stopType'].val == 'duration (frames)':
114             durationSecsStr = "%(stopVal)s*frameDur" % (self.params)
115         elif self.params['stopType'].val == 'frame N':
116             durationSecsStr = "(%(stopVal)s-frameN)*frameDur" % (self.params)
117         else:
118             msg = ("Couldn't deduce end point for startType=%(startType)s, "
119                    "stopType=%(stopType)s")
120             raise Exception(msg % self.params)
121         vals = (self.params['name'], durationSecsStr)
122         buff.writeIndented("%s.start(%s)\n" % vals)
123 
124     def writeStopTestCode(self, buff):
125         """Test whether we need to stop
126         """
127         code = ("elif %(name)s.status == STARTED:  # one frame should "
128                 "pass before updating params and completing\n")
129         buff.writeIndented(code % self.params)
130         buff.setIndentLevel(+1, relative=True)  # entered an if statement
131         self.writeParamUpdates(buff)
132         code = "%(name)s.complete()  # finish the static period\n"
133         buff.writeIndented(code % self.params)
134         # to get out of the if statement
135         buff.setIndentLevel(-1, relative=True)
136 
137         # pass  # the clock.StaticPeriod class handles its own stopping
138 
139     def writeParamUpdates(self, buff, updateType=None, paramNames=None):
140         """Write updates. Unlike most components, which us this method
141         to update themselves, the Static Component uses this to update
142         *other* components
143         """
144         if updateType == 'set every repeat':
145             return  # the static component doesn't need to change itself
146         if len(self.updatesList):
147             code = "# updating other components during *%s*\n"
148             buff.writeIndented(code % self.params['name'])
149             for update in self.updatesList:
150                 # update = {'compName':compName,'fieldName':fieldName,
151                 #    'routine':routine}
152                 compName = update['compName']
153                 fieldName = update['fieldName']
154                 routine = self.exp.routines[update['routine']]
155                 if hasattr(compName, 'params'):
156                     prms = compName.params  # it's already a compon so get params
157                 else:
158                     # it's a name so get compon and then get params
159                     prms = self.exp.getComponentFromName(str(compName)).params
160                 self.writeParamUpdate(buff, compName=compName,
161                                       paramName=fieldName,
162                                       val=prms[fieldName],
163                                       updateType=prms[fieldName].updates,
164                                       params=prms)
165             code = "# component updates done\n"
166             buff.writeIndented(code)
167
```
--- 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/psychopy/experiment/components/static/__init__.py b/psychopy/experiment/components/static/__init__.py
--- a/psychopy/experiment/components/static/__init__.py
+++ b/psychopy/experiment/components/static/__init__.py
@@ -163,4 +163,11 @@
                                       updateType=prms[fieldName].updates,
                                       params=prms)
             code = "# component updates done\n"
-            buff.writeIndented(code)
+
+            # Write custom code
+            if self.params['code']:
+                code += ("# Adding custom code for {name}\n"
+                         "{code}\n".format(name=self.params['name'],
+                                           code=self.params['code']))
+
+            buff.writeIndentedLines(code)

{"golden_diff": "diff --git a/psychopy/experiment/components/static/__init__.py b/psychopy/experiment/components/static/__init__.py\n--- a/psychopy/experiment/components/static/__init__.py\n+++ b/psychopy/experiment/components/static/__init__.py\n@@ -163,4 +163,11 @@\n                                       updateType=prms[fieldName].updates,\n                                       params=prms)\n             code = \"# component updates done\\n\"\n-            buff.writeIndented(code)\n+\n+            # Write custom code\n+            if self.params['code']:\n+                code += (\"# Adding custom code for {name}\\n\"\n+                         \"{code}\\n\".format(name=self.params['name'],\n+                                           code=self.params['code']))\n+\n+            buff.writeIndentedLines(code)\n", "issue": "Setting \"Custom code\" in StaticComponent doesn't seem to have any effect\nThe generated script doesn't contain any traces of the `Custom code` entered in the `StaticComponent`'s properties dialog.\r\n\r\n`psychopy:master`\n", "before_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"\nPart of the PsychoPy library\nCopyright (C) 2018 Jonathan Peirce\nDistributed under the terms of the GNU General Public License (GPL).\n\"\"\"\n\nfrom __future__ import absolute_import, print_function\n\nfrom builtins import str\nfrom os import path\nfrom psychopy.experiment.components import BaseComponent, Param, _translate\n\n__author__ = 'Jon Peirce'\n\n# the absolute path to the folder containing this path\nthisFolder = path.abspath(path.dirname(__file__))\niconFile = path.join(thisFolder, 'static.png')\ntooltip = _translate('Static: Static screen period (e.g. an ISI). '\n                     'Useful for pre-loading stimuli.')\n_localized = {'Custom code': _translate('Custom code')}\n\n\nclass StaticComponent(BaseComponent):\n    \"\"\"A Static Component, allowing frame rendering to pause.\n\n    E.g., pause while disk is accessed for loading an image\n    \"\"\"\n    # override the categories property below\n    # an attribute of the class, determines the section in the components panel\n    categories = ['Custom']\n\n    def __init__(self, exp, parentName, name='ISI',\n                 startType='time (s)', startVal=0.0,\n                 stopType='duration (s)', stopVal=0.5,\n                 startEstim='', durationEstim=''):\n        BaseComponent.__init__(self, exp, parentName, name=name)\n        self.updatesList = []  # a list of dicts {compParams, fieldName}\n        self.type = 'Static'\n        self.url = \"http://www.psychopy.org/builder/components/static.html\"\n        hnt = _translate(\n            \"Custom code to be run during the static period (after updates)\")\n        self.params['code'] = Param(\"\", valType='code',\n                                    hint=hnt,\n                                    label=_localized['Custom code'])\n        self.order = ['name']  # make name come first (others don't matter)\n\n        hnt = _translate(\"How do you want to define your start point?\")\n        self.params['startType'] = Param(startType, valType='str',\n                                         allowedVals=['time (s)', 'frame N'],\n                                         hint=hnt)\n        hnt = _translate(\"How do you want to define your end point?\")\n        _allow = ['duration (s)', 'duration (frames)', 'time (s)', 'frame N']\n        self.params['stopType'] = Param(stopType, valType='str',\n                                        allowedVals=_allow,  # copy not needed\n                                        hint=hnt)\n        hnt = _translate(\"When does the component start?\")\n        self.params['startVal'] = Param(startVal, valType='code',\n                                        allowedTypes=[],\n                                        hint=hnt)\n        hnt = _translate(\"When does the component end? (blank is endless)\")\n        self.params['stopVal'] = Param(stopVal, valType='code',\n                                       allowedTypes=[],\n                                       updates='constant', allowedUpdates=[],\n                                       hint=hnt)\n        hnt = _translate(\"(Optional) expected start (s), purely for \"\n                         \"representing in the timeline\")\n        self.params['startEstim'] = Param(startEstim, valType='code',\n                                          allowedTypes=[],\n                                          hint=hnt)\n        hnt = _translate(\"(Optional) expected duration (s), purely for \"\n                         \"representing in the timeline\")\n        self.params['durationEstim'] = Param(durationEstim, valType='code',\n                                             allowedTypes=[],\n                                             hint=hnt)\n\n    def addComponentUpdate(self, routine, compName, fieldName):\n        self.updatesList.append({'compName': compName,\n                                 'fieldName': fieldName,\n                                 'routine': routine})\n\n    def remComponentUpdate(self, routine, compName, fieldName):\n        # have to do this in a loop rather than a simple remove\n        target = {'compName': compName, 'fieldName': fieldName,\n                  'routine': routine}\n        for item in self.updatesList:\n            if item == target:\n                self.updatesList.remove(item)\n\n    def writeInitCode(self, buff):\n        code = (\"%(name)s = clock.StaticPeriod(win=win, \"\n                \"screenHz=expInfo['frameRate'], name='%(name)s')\\n\")\n        buff.writeIndented(code % self.params)\n\n    def writeFrameCode(self, buff):\n        self.writeStartTestCode(buff)\n        # to get out of the if statement\n        buff.setIndentLevel(-1, relative=True)\n        self.writeStopTestCode(buff)\n\n    def writeStartTestCode(self, buff):\n        \"\"\"This will be executed as the final component in the routine\n        \"\"\"\n        buff.writeIndented(\"# *%s* period\\n\" % (self.params['name']))\n        BaseComponent.writeStartTestCode(self, buff)\n\n        if self.params['stopType'].val == 'time (s)':\n            durationSecsStr = \"%(stopVal)s-t\" % (self.params)\n        elif self.params['stopType'].val == 'duration (s)':\n            durationSecsStr = \"%(stopVal)s\" % (self.params)\n        elif self.params['stopType'].val == 'duration (frames)':\n            durationSecsStr = \"%(stopVal)s*frameDur\" % (self.params)\n        elif self.params['stopType'].val == 'frame N':\n            durationSecsStr = \"(%(stopVal)s-frameN)*frameDur\" % (self.params)\n        else:\n            msg = (\"Couldn't deduce end point for startType=%(startType)s, \"\n                   \"stopType=%(stopType)s\")\n            raise Exception(msg % self.params)\n        vals = (self.params['name'], durationSecsStr)\n        buff.writeIndented(\"%s.start(%s)\\n\" % vals)\n\n    def writeStopTestCode(self, buff):\n        \"\"\"Test whether we need to stop\n        \"\"\"\n        code = (\"elif %(name)s.status == STARTED:  # one frame should \"\n                \"pass before updating params and completing\\n\")\n        buff.writeIndented(code % self.params)\n        buff.setIndentLevel(+1, relative=True)  # entered an if statement\n        self.writeParamUpdates(buff)\n        code = \"%(name)s.complete()  # finish the static period\\n\"\n        buff.writeIndented(code % self.params)\n        # to get out of the if statement\n        buff.setIndentLevel(-1, relative=True)\n\n        # pass  # the clock.StaticPeriod class handles its own stopping\n\n    def writeParamUpdates(self, buff, updateType=None, paramNames=None):\n        \"\"\"Write updates. Unlike most components, which us this method\n        to update themselves, the Static Component uses this to update\n        *other* components\n        \"\"\"\n        if updateType == 'set every repeat':\n            return  # the static component doesn't need to change itself\n        if len(self.updatesList):\n            code = \"# updating other components during *%s*\\n\"\n            buff.writeIndented(code % self.params['name'])\n            for update in self.updatesList:\n                # update = {'compName':compName,'fieldName':fieldName,\n                #    'routine':routine}\n                compName = update['compName']\n                fieldName = update['fieldName']\n                routine = self.exp.routines[update['routine']]\n                if hasattr(compName, 'params'):\n                    prms = compName.params  # it's already a compon so get params\n                else:\n                    # it's a name so get compon and then get params\n                    prms = self.exp.getComponentFromName(str(compName)).params\n                self.writeParamUpdate(buff, compName=compName,\n                                      paramName=fieldName,\n                                      val=prms[fieldName],\n                                      updateType=prms[fieldName].updates,\n                                      params=prms)\n            code = \"# component updates done\\n\"\n            buff.writeIndented(code)\n", "path": "psychopy/experiment/components/static/__init__.py"}], "after_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"\nPart of the PsychoPy library\nCopyright (C) 2018 Jonathan Peirce\nDistributed under the terms of the GNU General Public License (GPL).\n\"\"\"\n\nfrom __future__ import absolute_import, print_function\n\nfrom builtins import str\nfrom os import path\nfrom psychopy.experiment.components import BaseComponent, Param, _translate\n\n__author__ = 'Jon Peirce'\n\n# the absolute path to the folder containing this path\nthisFolder = path.abspath(path.dirname(__file__))\niconFile = path.join(thisFolder, 'static.png')\ntooltip = _translate('Static: Static screen period (e.g. an ISI). '\n                     'Useful for pre-loading stimuli.')\n_localized = {'Custom code': _translate('Custom code')}\n\n\nclass StaticComponent(BaseComponent):\n    \"\"\"A Static Component, allowing frame rendering to pause.\n\n    E.g., pause while disk is accessed for loading an image\n    \"\"\"\n    # override the categories property below\n    # an attribute of the class, determines the section in the components panel\n    categories = ['Custom']\n\n    def __init__(self, exp, parentName, name='ISI',\n                 startType='time (s)', startVal=0.0,\n                 stopType='duration (s)', stopVal=0.5,\n                 startEstim='', durationEstim=''):\n        BaseComponent.__init__(self, exp, parentName, name=name)\n        self.updatesList = []  # a list of dicts {compParams, fieldName}\n        self.type = 'Static'\n        self.url = \"http://www.psychopy.org/builder/components/static.html\"\n        hnt = _translate(\n            \"Custom code to be run during the static period (after updates)\")\n        self.params['code'] = Param(\"\", valType='code',\n                                    hint=hnt,\n                                    label=_localized['Custom code'])\n        self.order = ['name']  # make name come first (others don't matter)\n\n        hnt = _translate(\"How do you want to define your start point?\")\n        self.params['startType'] = Param(startType, valType='str',\n                                         allowedVals=['time (s)', 'frame N'],\n                                         hint=hnt)\n        hnt = _translate(\"How do you want to define your end point?\")\n        _allow = ['duration (s)', 'duration (frames)', 'time (s)', 'frame N']\n        self.params['stopType'] = Param(stopType, valType='str',\n                                        allowedVals=_allow,  # copy not needed\n                                        hint=hnt)\n        hnt = _translate(\"When does the component start?\")\n        self.params['startVal'] = Param(startVal, valType='code',\n                                        allowedTypes=[],\n                                        hint=hnt)\n        hnt = _translate(\"When does the component end? (blank is endless)\")\n        self.params['stopVal'] = Param(stopVal, valType='code',\n                                       allowedTypes=[],\n                                       updates='constant', allowedUpdates=[],\n                                       hint=hnt)\n        hnt = _translate(\"(Optional) expected start (s), purely for \"\n                         \"representing in the timeline\")\n        self.params['startEstim'] = Param(startEstim, valType='code',\n                                          allowedTypes=[],\n                                          hint=hnt)\n        hnt = _translate(\"(Optional) expected duration (s), purely for \"\n                         \"representing in the timeline\")\n        self.params['durationEstim'] = Param(durationEstim, valType='code',\n                                             allowedTypes=[],\n                                             hint=hnt)\n\n    def addComponentUpdate(self, routine, compName, fieldName):\n        self.updatesList.append({'compName': compName,\n                                 'fieldName': fieldName,\n                                 'routine': routine})\n\n    def remComponentUpdate(self, routine, compName, fieldName):\n        # have to do this in a loop rather than a simple remove\n        target = {'compName': compName, 'fieldName': fieldName,\n                  'routine': routine}\n        for item in self.updatesList:\n            if item == target:\n                self.updatesList.remove(item)\n\n    def writeInitCode(self, buff):\n        code = (\"%(name)s = clock.StaticPeriod(win=win, \"\n                \"screenHz=expInfo['frameRate'], name='%(name)s')\\n\")\n        buff.writeIndented(code % self.params)\n\n    def writeFrameCode(self, buff):\n        self.writeStartTestCode(buff)\n        # to get out of the if statement\n        buff.setIndentLevel(-1, relative=True)\n        self.writeStopTestCode(buff)\n\n    def writeStartTestCode(self, buff):\n        \"\"\"This will be executed as the final component in the routine\n        \"\"\"\n        buff.writeIndented(\"# *%s* period\\n\" % (self.params['name']))\n        BaseComponent.writeStartTestCode(self, buff)\n\n        if self.params['stopType'].val == 'time (s)':\n            durationSecsStr = \"%(stopVal)s-t\" % (self.params)\n        elif self.params['stopType'].val == 'duration (s)':\n            durationSecsStr = \"%(stopVal)s\" % (self.params)\n        elif self.params['stopType'].val == 'duration (frames)':\n            durationSecsStr = \"%(stopVal)s*frameDur\" % (self.params)\n        elif self.params['stopType'].val == 'frame N':\n            durationSecsStr = \"(%(stopVal)s-frameN)*frameDur\" % (self.params)\n        else:\n            msg = (\"Couldn't deduce end point for startType=%(startType)s, \"\n                   \"stopType=%(stopType)s\")\n            raise Exception(msg % self.params)\n        vals = (self.params['name'], durationSecsStr)\n        buff.writeIndented(\"%s.start(%s)\\n\" % vals)\n\n    def writeStopTestCode(self, buff):\n        \"\"\"Test whether we need to stop\n        \"\"\"\n        code = (\"elif %(name)s.status == STARTED:  # one frame should \"\n                \"pass before updating params and completing\\n\")\n        buff.writeIndented(code % self.params)\n        buff.setIndentLevel(+1, relative=True)  # entered an if statement\n        self.writeParamUpdates(buff)\n        code = \"%(name)s.complete()  # finish the static period\\n\"\n        buff.writeIndented(code % self.params)\n        # to get out of the if statement\n        buff.setIndentLevel(-1, relative=True)\n\n        # pass  # the clock.StaticPeriod class handles its own stopping\n\n    def writeParamUpdates(self, buff, updateType=None, paramNames=None):\n        \"\"\"Write updates. Unlike most components, which us this method\n        to update themselves, the Static Component uses this to update\n        *other* components\n        \"\"\"\n        if updateType == 'set every repeat':\n            return  # the static component doesn't need to change itself\n        if len(self.updatesList):\n            code = \"# updating other components during *%s*\\n\"\n            buff.writeIndented(code % self.params['name'])\n            for update in self.updatesList:\n                # update = {'compName':compName,'fieldName':fieldName,\n                #    'routine':routine}\n                compName = update['compName']\n                fieldName = update['fieldName']\n                routine = self.exp.routines[update['routine']]\n                if hasattr(compName, 'params'):\n                    prms = compName.params  # it's already a compon so get params\n                else:\n                    # it's a name so get compon and then get params\n                    prms = self.exp.getComponentFromName(str(compName)).params\n                self.writeParamUpdate(buff, compName=compName,\n                                      paramName=fieldName,\n                                      val=prms[fieldName],\n                                      updateType=prms[fieldName].updates,\n                                      params=prms)\n            code = \"# component updates done\\n\"\n\n            # Write custom code\n            if self.params['code']:\n                code += (\"# Adding custom code for {name}\\n\"\n                         \"{code}\\n\".format(name=self.params['name'],\n                                           code=self.params['code']))\n\n            buff.writeIndentedLines(code)\n", "path": "psychopy/experiment/components/static/__init__.py"}]}