Skip to content

Commit 9ce8153

Browse files
committed
player's config file will be saved even if it has to be created
1 parent e272b69 commit 9ce8153

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

pyradio/player.py

+22-22
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ def _do_save_volume(self, config_string):
108108
try:
109109
with open(config_file, "w") as c_file:
110110
c_file.write(config_string)
111+
self.volume = -1
111112
except:
112113
if (logger.isEnabledFor(logging.DEBUG)):
113114
logger.debug(log_strings[2].format(config_file))
114115
return ret_strings[2].format(str(self.volume))
115-
self.volume = -1
116116
else:
117117
if self.PROFILE_FROM_USER:
118118
with open(config_file, 'r') as c_file:
@@ -159,31 +159,31 @@ def _do_save_volume(self, config_string):
159159
try:
160160
with open(config_file, "w") as c_file:
161161
c_file.write(config_string)
162+
self.volume = -1
162163
except EnvironmentError:
163164
if (logger.isEnabledFor(logging.DEBUG)):
164165
logger.debug(log_strings[2].format(config_file))
165166
return ret_strings[2].format(str(self.volume))
166-
self.volume = -1
167167

168-
""" no user profile or user config file does not exist """
169-
if not profile_found:
170-
if not os.path.isdir(os.path.dirname(config_file)):
171-
try:
172-
os.mkdir(os.path.dirname(config_file))
173-
except OSError:
174-
if (logger.isEnabledFor(logging.DEBUG)):
175-
logger.debug(log_strings[2].format(config_file))
176-
return ret_strings[2].format(str(self.volume))
177-
new_profile_string = "volume=100\n\n" + config_string
178-
try:
179-
with open(config_file, "a") as c_file:
180-
c_file.write(new_profile_string.format(str(self.volume)))
181-
except EnvironmentError:
182-
if (logger.isEnabledFor(logging.DEBUG)):
183-
logger.debug(log_strings[2].format(config_file))
184-
return ret_strings[2].format(str(self.volume))
185-
self.volume = -1
186-
self.PROFILE_FROM_USER = True
168+
""" no user profile or user config file does not exist """
169+
if not profile_found:
170+
if not os.path.isdir(os.path.dirname(config_file)):
171+
try:
172+
os.mkdir(os.path.dirname(config_file))
173+
except OSError:
174+
if (logger.isEnabledFor(logging.DEBUG)):
175+
logger.debug(log_strings[2].format(config_file))
176+
return ret_strings[2].format(str(self.volume))
177+
new_profile_string = "volume=100\n\n" + config_string
178+
try:
179+
with open(config_file, "a") as c_file:
180+
c_file.write(new_profile_string.format(str(self.volume)))
181+
except EnvironmentError:
182+
if (logger.isEnabledFor(logging.DEBUG)):
183+
logger.debug(log_strings[2].format(config_file))
184+
return ret_strings[2].format(str(self.volume))
185+
self.volume = -1
186+
self.PROFILE_FROM_USER = True
187187
return ret_string
188188

189189
def _is_in_playback_token(self, a_string):
@@ -671,7 +671,7 @@ def _diaplay_mpv_volume_value(self):
671671
string_to_show = self._format_volume_string('Volume: ' + str(vol) + '%') + info_string
672672
self.outputStream.write(string_to_show)
673673
self.threadUpdateTitle(self.status_update_lock)
674-
self.volume = str(vol)
674+
self.volume = vol
675675

676676

677677
class MpPlayer(Player):

0 commit comments

Comments
 (0)