ArielGlenn has submitted this change and it was merged.

Change subject: enable directory prompt in cli in a few places in the menu
......................................................................


enable directory prompt in cli in a few places in the menu

Change-Id: I922b1ce2564fbeae5b8421f5525b7d509d7950f8
---
M dataretention/retention/cli.py
M dataretention/retention/completion.py
2 files changed, 20 insertions(+), 19 deletions(-)

Approvals:
  ArielGlenn: Verified; Looks good to me, approved



diff --git a/dataretention/retention/cli.py b/dataretention/retention/cli.py
index 04d29fb..6e3a325 100644
--- a/dataretention/retention/cli.py
+++ b/dataretention/retention/cli.py
@@ -29,6 +29,7 @@
         self.cwdir = path
         self.problem_dirs = problems
         self.skipped_dirs = skipped
+        self.prompt = ''
 
     def clear(self):
         self.host = None
@@ -43,6 +44,14 @@
     def set_reported_dirs(self, problems, skipped):
         self.problem_dirs = problems
         self.skipped_dirs = skipped
+
+    def set_prompt(self):
+        if self.cwdir is None:
+            self.prompt = "> "
+        elif len(self.cwdir) < 15:
+            self.prompt = self.cwdir + ">"
+        else:
+            self.prompt = "..." + self.cwdir[-12:] + ">"
 
 
 class CurrentDirContents(object):
@@ -304,7 +313,8 @@
 
     def get_menu_entry(self, choices, default, text):
         self.cmpl.set_choices_completion(choices, default)
-        command = raw_input(text + " [%s]: " % default)
+        self.cenv.set_prompt()
+        command = raw_input(self.cenv.prompt + ' ' + text + " [%s]: " % 
default)
         command = command.strip()
         if command == "":
             command = default
@@ -400,15 +410,6 @@
             return False
 
         return True
-
-    # fixme use this (also make it have first + last, more helpful prolly)
-    def set_prompt(self):
-        if self.cenv.cwdir is None:
-            self.prompt = "> "
-        elif len(self.cenv.cwdir) < 10:
-            self.prompt = self.cenv.cwdir + ">"
-        else:
-            self.prompt = "..." + self.cenv.cwdir[-7:] + ">"
 
     def get_entries_from_wildcard(self, file_expr):
         '''
@@ -532,7 +533,7 @@
                     return True
                 elif status[0].upper() in Status.STATUSES:
                     clouseau.retention.ruleutils.show_rules(self.cdb, 
self.cenv.host, status[0].upper(),
-                                                   prefix=prefix)
+                                                            prefix=prefix)
                     return True
         elif command == 'D' or command == 'd':
             self.dircontents.get(self.cenv.host, self.cenv.cwdir, self.batchno)
@@ -541,8 +542,8 @@
         elif command == 'C' or command == 'c':
             self.dircontents.get(self.cenv.host, self.cenv.cwdir, self.batchno)
             clouseau.retention.ruleutils.get_rules_for_entries(self.cdb, 
self.cenv.cwdir,
-                                                      
self.dircontents.entries_dict,
-                                                      self.cenv.host)
+                                                               
self.dircontents.entries_dict,
+                                                               self.cenv.host)
             return True
         elif command == 'R' or command == 'r':
             # fixme need different completer here I think, that
@@ -639,7 +640,8 @@
             while True:
                 # prompt user for dir to descend
                 readline.set_completer(self.cmpl.dir_completion)
-                directory = raw_input("directory name (empty to quit): ")
+                self.cenv.set_prompt()
+                directory = raw_input(self.cenv.prompt + ' ' + "directory name 
(empty to quit): ")
                 directory = directory.strip()
                 if directory == '':
                     return command
@@ -654,14 +656,14 @@
                     self.cenv.cwdir = os.path.join(self.cenv.cwdir,
                                                    directory)
                     self.dircontents.clear()
-                    self.set_prompt()
+                    self.cenv.set_prompt()
                     print 'Now at', self.cenv.cwdir
                     return True
         elif command == 'U' or command == 'u':
             if self.cenv.cwdir != self.basedir:
                 self.cenv.cwdir = os.path.dirname(self.cenv.cwdir)
                 self.dircontents.clear()
-                self.set_prompt()
+                self.cenv.set_prompt()
                 print 'Now at', self.cenv.cwdir
             else:
                 print 'Already at top', self.cenv.cwdir
@@ -741,8 +743,8 @@
                 # this option is invoked on a directory so
                 # type is dir every time
                 clouseau.retention.ruleutils.do_add_rule(self.cdb, dir_path,
-                                                
clouseau.retention.ruleutils.text_to_entrytype('dir'),
-                                                command, self.cenv.host)
+                                                         
clouseau.retention.ruleutils.text_to_entrytype('dir'),
+                                                         command, 
self.cenv.host)
                 return None
             elif command == 'Q' or command == 'q':
                 return None
diff --git a/dataretention/retention/completion.py 
b/dataretention/retention/completion.py
index 7478165..1c55fe5 100644
--- a/dataretention/retention/completion.py
+++ b/dataretention/retention/completion.py
@@ -99,7 +99,6 @@
         prompt user for host in self.hostlist,
         with tab completion
         '''
-
         readline.set_completer(self.dir_completion)
         dir_todo = raw_input("Directory (blank to exit): ")
         dir_todo = dir_todo.strip()

-- 
To view, visit https://gerrit.wikimedia.org/r/233469
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I922b1ce2564fbeae5b8421f5525b7d509d7950f8
Gerrit-PatchSet: 2
Gerrit-Project: operations/software
Gerrit-Branch: master
Gerrit-Owner: ArielGlenn <[email protected]>
Gerrit-Reviewer: ArielGlenn <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to