Package omero :: Package util
[hide private]
[frames] | no frames]

Package util

source code

Submodules [hide private]

Classes [hide private]
  StreamRedirect
Since all server components should exclusively using the logging module any output to stdout or stderr is caught and logged at "WARN".
  Dependency
Centralized logic for declaring and logging a service dependency on a non-shipped library.
  ServerContext
Context passed to all servants.
  Server
Basic server implementation which can be used for implementing a standalone python server which can be started from icegridnode.
  SimpleServant
Base servant initialization.
  Servant
Abstract servant which can be used along with a slice2py generated dispatch class as the base type of high-level servants.
  Resources
Container class for storing resources which should be cleaned up on close and periodically checked.
  Environment
Simple class for creating an executable environment
Functions [hide private]
 
make_logname(self)
Generates a logname from the given instance using the module and name from its class
source code
 
configure_logging(logdir=None, logfile=None, loglevel=LOGLEVEL, format=LOGFORMAT, filemode=LOGMODE, maxBytes=LOGSIZE, backupCount=LOGNUM, time_rollover=False) source code
 
configure_server_logging(props)
Takes an Ice.Properties instance and configures logging
source code
 
internal_service_factory(communicator, user="root", group=None, retries=6, interval=10, client_uuid=None, stop_event=None)
Try to return a ServiceFactory from the grid.
source code
 
create_admin_session(communicator) source code
 
add_grid_object(communicator, obj) source code
 
long_to_path(id, root="")
Converts a long to a path such that for all directiories only a 1000 files and a 1000 subdirectories will be returned.
source code
 
get_user(default=None)
Returns the username.
source code
 
get_user_dir() source code
 
edit_path(path_or_obj, start_text) source code
 
tail_lines(filename, linesback=10, returnlist=0)
Does what "tail -10 filename" would have done Parameters:
source code
Variables [hide private]
  LOGDIR = os.path.join("var", "log")
  LOGFORMAT = """%(asctime)s %(levelname)-5.5s [%(name)40s] (%(t...
  LOGLEVEL = logging.INFO
  LOGSIZE = 500000000
  LOGNUM = 9
  LOGMODE = "a"
  orig_stdout = sys.stdout
  orig_stderr = sys.stderr

Imports: os, sys, Ice, path, time, IcePy, IceGrid, platform, Glacier2, threading, exceptions, logging, omero, uuid, locked


Function Details [hide private]

internal_service_factory(communicator, user="root", group=None, retries=6, interval=10, client_uuid=None, stop_event=None)

source code 

Try to return a ServiceFactory from the grid.

Try a number of times then give up and raise the last exception returned. This method will only work internally to the grid, i.e. behind the Glacier2 firewall. It is intended for internal servers to be able to create sessions for accessing the database. :

   communicator := Ice.Communicator used to find the registry
   user         := Username which should have a session created
   group        := Group into which the session should be logged
   retries      := Number of session creation retries before throwing
   interval     := Seconds between retries
   client_uuid  := Uuid of the client which should be used

long_to_path(id, root="")

source code 

Converts a long to a path such that for all directiories only a 1000 files and a 1000 subdirectories will be returned.

This method duplicates the logic in ome.io.nio.AbstractFileSystemService.java:getPath()

get_user(default=None)

source code 

Returns the username. For most purposes, this value will be the same as getpass.getuser on *nix and win32api.GetUserName on Windows, but in some situations (when running without a terminal, etc) getuser may throw a KeyError. In which case, or if the username resolves to False, the default value be returned.

Any unexpected exceptions will be thrown.

See ticket:6307

tail_lines(filename, linesback=10, returnlist=0)

source code 

Does what "tail -10 filename" would have done Parameters:

    filename   file to read
    linesback  Number of lines to read from end of file
    returnlist Return a list containing the lines instead of a string

Variables Details [hide private]

LOGFORMAT

Value:
"""%(asctime)s %(levelname)-5.5s [%(name)40s] (%(threadName)-10s) %(me\
ssage)s"""