Skip to content

Commit

Permalink
Merge pull request #347 from PyPlanet/bugfix/334
Browse files Browse the repository at this point in the history
Bugfix/334
  • Loading branch information
tomvlk committed Jun 3, 2017
2 parents 88d1ab4 + ecfda4b commit e671a67
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 21 deletions.
8 changes: 8 additions & 0 deletions pyplanet/apps/contrib/info/templates/mapinfo.Script.Txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

declare CMlLabel Author_Label <=> (Page.GetFirstChild("author_label") as CMlLabel);
declare CMlQuad Author_Flag <=> (Page.GetFirstChild("author_flag") as CMlQuad);

if (Map != Null) {
Author_Label.SetText(Map.AuthorNickName);
Author_Flag.ChangeImageUrl(Map.AuthorZoneIconUrl);
}
10 changes: 8 additions & 2 deletions pyplanet/apps/contrib/info/templates/mapinfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@

<quad pos="0 -6.5" z-index="0" size="35 6" bgcolor="00000060"/>
<quad pos="0 -6.5" z-index="0" size="6.5 6" bgcolor="00000060"/>
<quad pos="0.5 -6.75" z-index="1" size="5.5 5" image="file://Media/Flags/samerica.dds"/> <!-- TODO: Use flag of author -->
<label pos="21.5 -9.5" z-index="1" size="28 6" text="{{ map_author }}" textsize="1.6" valign="center2" halign="center" textfont="RajdhaniMono" textemboss="1"/>
<quad pos="0.9 -7.35" z-index="1" size="4.80 4.25" image="file://Media/Flags/samerica.dds" id="author_flag" /> <!-- TODO: Use flag of author -->
<label pos="21.5 -9.5" z-index="1" size="28 6"
data-login="{{ map_author }}" text="-" textsize="1.6"
valign="center2" halign="center" textfont="RajdhaniMono" textemboss="1"
id="author_label"
/>

<quad pos="0 -13" z-index="0" size="40 6" bgcolor="00000060"/>
<quad pos="0 -13" z-index="0" size="6.5 6" bgcolor="00000060"/>
<label pos="1.25 -13.75" z-index="1" size="5 5" text="&#xf017;"/>
<label pos="21.5 -16.25" z-index="1" size="28 6" text="{{ map_authortime }}" textsize="1.6" valign="center2" halign="center" textfont="RajdhaniMono" textemboss="1"/>

<script><!--{% include 'info/mapinfo.Script.Txt' %}--></script>
{% endblock %}
10 changes: 2 additions & 8 deletions pyplanet/apps/contrib/info/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

from pyplanet import __version__ as version
from pyplanet.apps.core.maniaplanet.models import Player
from pyplanet.views.generics.widget import WidgetView
from pyplanet.utils import times
from pyplanet.contrib.player.exceptions import PlayerNotFound
Expand All @@ -19,18 +20,11 @@ def __init__(self, app):

async def get_context_data(self):
map = self.app.instance.map_manager.current_map
map_author = map.author_login
try:
author = await self.app.instance.player_manager.get_player(map.author_login)
map_author = author.nickname
except PlayerNotFound:
if map.author_nickname:
map_author = map.author_nickname

context = await super().get_context_data()
context.update({
'map_name': map.name,
'map_author': map_author,
'map_author': map.author_login,
'map_authortime': times.format_time(map.time_author) if map.time_author and map.time_author > 0 else '-',
'map_environment': map.environment,
})
Expand Down
10 changes: 5 additions & 5 deletions pyplanet/god/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
class EnvironmentPool:
"""
This class manages the pool instances for the current environment/installation.
.. warning::
You should not have to use this class in any moment!
"""

def __init__(self, pool_names, max_restarts=0):
Expand Down Expand Up @@ -57,7 +57,7 @@ def start(self):
Start all processes.
"""
for name, proc in self.pool.items():
proc.process.start()
proc.start()

def shutdown(self):
"""
Expand All @@ -71,7 +71,7 @@ def shutdown(self):
def restart(self, name=None):
"""
Restart single process, or all if no name is given.
:param name: Name or none for all pools.
"""
if name:
Expand Down
12 changes: 6 additions & 6 deletions pyplanet/god/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
def _run(name, queue):
"""
The actual process that runs the separate controller instance.
:param name: name of the process
:type name: str
"""
Expand Down Expand Up @@ -40,17 +40,17 @@ def _run(name, queue):
class InstanceProcess:
"""
The InstanceProcess is the encapsulation around the real controller instance.
.. warning::
This code is still being executed at the main process!!
"""

def __init__(self, queue, environment_name='default', pool=None):
"""
Create an environment process of the controller itself.
:param queue: Queue to hook on.
:param environment_name: Name of environment.
:param pool: Pool.
Expand Down Expand Up @@ -85,15 +85,15 @@ def did_die(self):
def exitcode(self):
"""
Exit code of process.
:return: Exit code.
"""
return self.process.exitcode

@property
def will_restart(self):
"""
Boolean: Is the process able to restart (not reached max_restarts).
Boolean: Is the process able to restart (not reached max_restarts).
"""
return self.restarts < self.max_restarts

Expand Down

0 comments on commit e671a67

Please sign in to comment.