[PATCH] Update Platform instance from flags instead of replacing it. (#1090646)

David Lehman dlehman at redhat.com
Fri Apr 25 12:59:53 UTC 2014



On 04/25/2014 06:53 AM, Anne Mulhern wrote:
>
>
>
>
> ----- Original Message -----
>> From: "David Lehman" <dlehman at redhat.com>
>> To: anaconda-patches at lists.fedorahosted.org
>> Sent: Thursday, April 24, 2014 4:00:05 PM
>> Subject: [PATCH] Update Platform instance from flags instead of replacing it.	(#1090646)
>>
>> Replacing the platform instance as a means of picking up changes to
>> flags doesn't work because most modules will still have the now-defunct
>> Platform instance in their namespace. This patch changes the flags
>> update so that it updates the Platform instance in-place, allowing the
>> modules that have already imported it to get the updates.
>> ---
>>   blivet/__init__.py | 3 +--
>>   blivet/platform.py | 7 +++----
>>   2 files changed, 4 insertions(+), 6 deletions(-)
>>
>> diff --git a/blivet/__init__.py b/blivet/__init__.py
>> index 68d4539..eec0bb8 100644
>> --- a/blivet/__init__.py
>> +++ b/blivet/__init__.py
>> @@ -129,8 +129,7 @@ def storageInitialize(storage, ksdata, protected):
>>       flags.update_from_anaconda_flags(anaconda_flags)
>>
>>       # Platform class setup depends on flags, re-initialize it.
>> -    from . import platform
>> -    platform.reset_platform()
>> +    _platform.update_from_flags()
>>
>>       storage.shutdown()
>>
>> diff --git a/blivet/platform.py b/blivet/platform.py
>> index 00dd80e..07a4f58 100644
>> --- a/blivet/platform.py
>> +++ b/blivet/platform.py
>> @@ -63,6 +63,9 @@ class Platform(object):
>>              returned by getPlatform below.  Not all subclasses need to
>>              provide
>>              all the methods in this class."""
>>
>> +        self.update_from_flags()
>> +
>> +    def update_from_flags(self):
>>           if flags.gpt and "gpt" in self._disklabel_types:
>>               # move GPT to the top of the list
>>               self._disklabel_types.remove("gpt")
>> @@ -418,8 +421,4 @@ def getPlatform():
>>       else:
>>           raise SystemError("Could not determine system architecture.")
>>
>> -def reset_platform():
>> -    global platform
>> -    platform = getPlatform()
>> -
>>   platform = getPlatform()
>> --
>> 1.9.0
>>
>> _______________________________________________
>> anaconda-patches mailing list
>> anaconda-patches at lists.fedorahosted.org
>> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
>>
>
> In commit message could you change
> "most modules" to "already loaded modules which explicitly import
> platform from platform"?

Sure.

>
> - mulhern
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
>


More information about the anaconda-patches mailing list