<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def run_script(self, filename):
 """ Run a python script in QGIS to exercise InaSAFE functionality. This functionality was originally intended for verifying that the key elements are InaSAFE are loading correctly and available. However, the utility of this function is such that you can run any arbitrary python scripts with it. As such you can use it it automate activities in QGIS, for example automatically running an impact assessment in response to an event. :param filename: the script filename. :type filename: str """

        module, _ = os.path.splitext(filename)
        if module in sys.modules:
            script = reload(sys.modules[module])
        else:
            script = __import__(module)

        # run entry function
        function = script.runScript
        if function.__code__.co_argcount == 1:
            function(self.iface)
        else:
            function()