Re: [PATCH 1/5] Move large anaconda.__main__ tasks into functions.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is just because you're touching this code, so it's a good
opportunity to do some cleanups too.

> +def setupDisplay(anaconda, opts):

I don't have anything to say here, except sweet merciful crap there has
got to be a better way.

> +def runDogtail(opts):
> +    try:
> +        import urlgrabber
> +
> +        try:
> +            fr = urlgrabber.urlopen(opts.dogtail)
> +        except urlgrabber.grabber.URLGrabError as e:
> +            log.error("Could not retrieve Dogtail script from %s.\nError "
> +                      "was\n%s" % (opts.dogtail, e))
> +            fr = None
> +
> +        if fr:
> +            (fw, testcase) = mkstemp(prefix='testcase.py.', dir='/tmp')
> +            os.write(fw, fr.read())
> +            fr.close()
> +            os.close(fw)
> +
> +            # download completed, run the test
> +            if not os.fork():
> +                # we are in the child
> +                os.chmod(testcase, 0755)
> +                os.execv(testcase, [testcase])
> +                sys.exit(0)
> +            else:
> +                # we are in the parent, sleep to give time for the testcase
> +                # to initialize
> +                # todo: is this needed, how to avoid possible race conditions
> +                time.sleep(1)
> +    except Exception as e:
> +        log.error("Exception %s while running Dogtail testcase" % e)

Can we get rid of the overarching try...except in favor of something a
little more targeted?

Also, in the inner except case, just return and then you can get rid of
the "if fr:" bit and un-indent all that code.  Maybe I'm just picky, but
I don't like indenting stuff more than I have to.  And making this a
function means we can do that.

- Chris

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux