Rename internal:time to .mudpy.timing
authorJeremy Stanley <fungi@yuggoth.org>
Sat, 29 Jul 2017 16:18:16 +0000 (16:18 +0000)
committerJeremy Stanley <fungi@yuggoth.org>
Sat, 29 Jul 2017 16:18:16 +0000 (16:18 +0000)
Convert the old style internal:time element to a new style
.mudpy.timing element and adjust the User.check_idle() method and
on_pulse() function accordingly.

etc/mudpy.yaml
mudpy/misc.py
mudpy/tests/fixtures/test_daemon.yaml

index ab7c9ed..dc82a45 100644 (file)
@@ -48,21 +48,17 @@ __control__:
 #.mudpy.process.daemon: true
 #.mudpy.process.pidfile: mudpy.pid
 
+.mudpy.timing.idle.disconnect.active: 6048000
+.mudpy.timing.idle.disconnect.default: 6000
+.mudpy.timing.idle.disconnect.entering_account_name: 600
+.mudpy.timing.idle.warn.active: 5040000
+.mudpy.timing.idle.warn.default: 5000
+.mudpy.timing.idle.warn.entering_account_name: 500
+.mudpy.timing.increment: 0.1
+.mudpy.timing.save: 600
+.mudpy.timing.status: 6000
+
 internal:storage:
     default_dir: "data"
     #root_path: "."
     search_path: [ "", "etc", "share", "data" ]
-
-internal:time:
-    definition_d: 24h
-    definition_h: 60mi
-    definition_mi: 10r
-    definition_mo: 28d
-    definition_r: 6
-    definition_w: 7d
-    definition_y: 12mo
-    frequency_log: 6000
-    frequency_save: 600
-    linkdead: { "default": 6000, "entering_account_name": 600, "active": 6048000 }
-    idle: { "default": 5000, "entering_account_name": 500, "active": 5040000 }
-    increment: 0.1
index fb651f6..f57fec3 100644 (file)
@@ -536,9 +536,8 @@ class User:
     def check_idle(self):
         """Warn or disconnect idle users as appropriate."""
         idletime = universe.get_time() - self.last_input
-        linkdead_dict = universe.categories["internal"]["time"].get(
-            "linkdead"
-        )
+        linkdead_dict = universe.contents[
+            "mudpy.timing.idle.disconnect"].facets()
         if self.state in linkdead_dict:
             linkdead_state = self.state
         else:
@@ -560,7 +559,7 @@ class User:
             log(logline, 2)
             self.state = "disconnecting"
             self.menu_seen = False
-        idle_dict = universe.categories["internal"]["time"].get("idle")
+        idle_dict = universe.contents["mudpy.timing.idle.warn"].facets()
         if self.state in idle_dict:
             idle_state = self.state
         else:
@@ -1371,9 +1370,7 @@ def on_pulse():
     if not universe.categories["internal"]["counters"].get("mark"):
         log(str(len(universe.userlist)) + " connection(s)")
         universe.categories["internal"]["counters"].set(
-            "mark", universe.categories["internal"]["time"].get(
-                "frequency_log"
-            )
+            "mark", universe.contents["mudpy.timing"].get("status")
         )
     else:
         universe.categories["internal"]["counters"].set(
@@ -1386,9 +1383,7 @@ def on_pulse():
     if not universe.categories["internal"]["counters"].get("save"):
         universe.save()
         universe.categories["internal"]["counters"].set(
-            "save", universe.categories["internal"]["time"].get(
-                "frequency_save"
-            )
+            "save", universe.contents["mudpy.timing"].get("save")
         )
     else:
         universe.categories["internal"]["counters"].set(
@@ -1398,8 +1393,7 @@ def on_pulse():
         )
 
     # pause for a configurable amount of time (decimal seconds)
-    time.sleep(universe.categories["internal"]
-               ["time"].get("increment"))
+    time.sleep(universe.contents["mudpy.timing"].get("increment"))
 
     # increase the elapsed increment counter
     universe.categories["internal"]["counters"].set(
index ac63091..f9d7c64 100644 (file)
@@ -48,21 +48,17 @@ __control__:
 .mudpy.process.daemon: true
 .mudpy.process.pidfile: var/mudpy.pid
 
+.mudpy.timing.idle.disconnect.active: 6048000
+.mudpy.timing.idle.disconnect.default: 6000
+.mudpy.timing.idle.disconnect.entering_account_name: 600
+.mudpy.timing.idle.warn.active: 5040000
+.mudpy.timing.idle.warn.default: 5000
+.mudpy.timing.idle.warn.entering_account_name: 500
+.mudpy.timing.increment: 0.1
+.mudpy.timing.save: 5
+.mudpy.timing.status: 25
+
 internal:storage:
     default_dir: "data"
     #root_path: "."
     search_path: [ "", "etc", "share", "data" ]
-
-internal:time:
-    definition_d: 24h
-    definition_h: 60mi
-    definition_mi: 10r
-    definition_mo: 28d
-    definition_r: 6
-    definition_w: 7d
-    definition_y: 12mo
-    frequency_log: 25
-    frequency_save: 5
-    linkdead: { "default": 6000, "entering_account_name": 600, "active": 6048000 }
-    idle: { "default": 5000, "entering_account_name": 500, "active": 5040000 }
-    increment: 0.1