rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
context.portal_membership.changeMemberPortrait(value)
context.portal_membership.changeMemberPortrait(value, context.id)
def set_portrait(self, value): if value: context = aq_inner(self.context) context.portal_membership.changeMemberPortrait(value)
context.portal_membership.deletePersonalPortrait()
context.portal_membership.deletePersonalPortrait(context.id)
def set_pdelete(self, value): if value: context = aq_inner(self.context) context.portal_membership.deletePersonalPortrait()
default=u'A short overview of who you are and ' 'author page, linked from the items you create.'),
default=u"A short overview of who you are and what you " "do. Will be displayed on your author page, linked " "from the items you create."),
def checkEmailAddress(value): portal = getUtility(ISiteRoot) reg_tool= getToolByName(portal, 'portal_registration') if value and reg_tool.isValidEmail(value): pass else: raise EmailAddressInvalid # If emails are used as logins, ensure that the address fits all constraints props = getToolByName(portal, 'portal_propert...
deprecatedModuleAttributes(
deprecatedModuleAttribute(
def badAPI(self, first, second): ''' Docstring for badAPI. ''' ...
L{deprecatedModuleAttributes} call is being made from, the C{__name__} global
L{deprecatedModuleAttribute} call is being made from, the C{__name__} global
def badAPI(self, first, second): ''' Docstring for badAPI. ''' ...
__all__ = ["deferToThread", "callMultipleInThread", "blockingCallFromThread"]
__all__ = ["deferToThread", "deferToThreadPool", "callMultipleInThread", "blockingCallFromThread"]
def _callFromThread(): result = defer.maybeDeferred(f, *a, **kw) result.addBoth(queue.put)
read events until it is removed from the reactor with
write events until it is removed from the reactor with
def addWriter(writer): """ I add writer to the set of file descriptors to get write events for.
New in 10.0.
New in 10.1.
def __init__(self, canceller=None): """ Initialize a L{Deferred}.
notifier.watch("/some/directory", callbacks=[notify])
notifier.watch(filepath.FilePath("/some/directory"), callbacks=[notify])
def notify(self, iwp, filepath, mask, extraArg): print "event %s on %s %s" % ( ', '.join(inotify.humanReadableMask(mask)), iwp.path, filepath)
class IUDPConnectedTransport(Interface): """ DEPRECATED. Transport for UDP ConnectedPacketProtocols. """ def write(packet): """ Write packet to address we are connected to. """ def getHost(): """ Returns L{UNIXAddress}. """
def stopListening(): """ Stop listening on this port.
See also: L{pb.getObjectAt}
def jellyFor(self, jellier): """(internal)
method.skip = 'pwd and spwd are both unavailable'
method.skip = ("Required module(s) are unavailable: " + ", ".join(availability))
def test_unixCheckerFailsPassword(self): """ Test that the checker fails with an invalid password. """ return self.assertFailure(self.checker.requestAvatarId(self.badPass), error.UnauthorizedLogin)
print ant.name, ant.sensor.target.get_value(), ant.sensor.mode.get_value(), ant.sensor.lock.get_value()
def on_target(self, target): """Determine whether antennas are tracking a given target.
target = getattr(target, 'description', target)
target = target if isinstance(target, katpoint.Target) else katpoint.Target(target)
def track(self, target, duration=20.0, drive_strategy='longest-track', label='track', announce=True): """Track a target.
user_logger.info("Initiating %g-second track on target '%s'" % (duration, preferred_name(target)))
user_logger.info("Initiating %g-second track on target '%s'" % (duration, target.name))
def track(self, target, duration=20.0, drive_strategy='longest-track', label='track', announce=True): """Track a target.
user_logger.warning("Skipping track, as target '%s' will be below horizon" % (preferred_name(target),))
user_logger.warning("Skipping track, as target '%s' will be below horizon" % (target.name,))
def track(self, target, duration=20.0, drive_strategy='longest-track', label='track', announce=True): """Track a target.
target = getattr(target, 'description', target)
target = target if isinstance(target, katpoint.Target) else katpoint.Target(target)
def scan(self, target, duration=30.0, start=-3.0, end=3.0, scan_in_azimuth=True, drive_strategy='shortest-slew', label='scan', announce=True): """Scan across a target.
user_logger.info("Initiating %g-second scan across target '%s'" % (duration, preferred_name(target)))
user_logger.info("Initiating %g-second scan across target '%s'" % (duration, target.name))
def scan(self, target, duration=30.0, start=-3.0, end=3.0, scan_in_azimuth=True, drive_strategy='shortest-slew', label='scan', announce=True): """Scan across a target.
user_logger.warning("Skipping scan, as target '%s' will be below horizon" % (preferred_name(target),))
user_logger.warning("Skipping scan, as target '%s' will be below horizon" % (target.name,))
def scan(self, target, duration=30.0, start=-3.0, end=3.0, scan_in_azimuth=True, drive_strategy='shortest-slew', label='scan', announce=True): """Scan across a target.
target = getattr(target, 'description', target)
target = target if isinstance(target, katpoint.Target) else katpoint.Target(target)
def raster_scan(self, target, num_scans=3, scan_duration=30.0, scan_extent=6.0, scan_spacing=0.5, scan_in_azimuth=True, drive_strategy='shortest-slew', label='raster', announce=True): """Perform raster scan on target.
(num_scans, scan_duration, scan_extent, preferred_name(target)))
(num_scans, scan_duration, scan_extent, target.name))
def raster_scan(self, target, num_scans=3, scan_duration=30.0, scan_extent=6.0, scan_spacing=0.5, scan_in_azimuth=True, drive_strategy='shortest-slew', label='raster', announce=True): """Perform raster scan on target.
user_logger.warning("Skipping raster scan, as target '%s' will be below horizon" % (preferred_name(target),))
user_logger.warning("Skipping raster scan, as target '%s' will be below horizon" % (target.name,))
def raster_scan(self, target, num_scans=3, scan_duration=30.0, scan_extent=6.0, scan_spacing=0.5, scan_in_azimuth=True, drive_strategy='shortest-slew', label='raster', announce=True): """Perform raster scan on target.
self.nd_params = None
self.nd_params = {'diode' : 'pin', 'on' : 0., 'off' : 0., 'period' : -1.}
def __init__(self, kat, experiment_id, observer, description, ants, record_slews=True, **kwargs): try: self.kat = kat self.experiment_id = experiment_id self.ants = ants = ant_array(kat, ants) self.record_slews = record_slews self.nd_params = None self.last_nd_firing = 0.
if session.nd_params is None: raise ValueError('No noise diode parameters set - please run session.standard_setup() first')
if announce: user_logger.info("Initiating %g-second track on target '%s'" % (duration, preferred_name(target))) if not session.target_visible(target, duration, operation='track'): user_logger.warning("Skipping track, as target '%s' will be below horizon" % (preferred_name(target),)) return False
def track(self, target, duration=20.0, drive_strategy='longest-track', label='track', announce=True): """Track a target.
if announce: user_logger.info("Initiating %g-second track on target '%s'" % (duration, preferred_name(target))) session.target_visible(target, duration, operation='track')
def track(self, target, duration=20.0, drive_strategy='longest-track', label='track', announce=True): """Track a target.
if session.nd_params is None: raise ValueError('No noise diode parameters set - please run session.standard_setup() first')
def scan(self, target, duration=30.0, start=-3.0, end=3.0, scan_in_azimuth=True, drive_strategy='shortest-slew', label='scan', announce=True): """Scan across a target.
session.target_visible(target, duration, operation='scan')
if not session.target_visible(target, duration, operation='scan'): user_logger.warning("Skipping scan, as target '%s' will be below horizon" % (preferred_name(target),)) return False
def scan(self, target, duration=30.0, start=-3.0, end=3.0, scan_in_azimuth=True, drive_strategy='shortest-slew', label='scan', announce=True): """Scan across a target.
if session.nd_params is None: raise ValueError('No noise diode parameters set - please run session.standard_setup() first')
def raster_scan(self, target, num_scans=3, scan_duration=30.0, scan_extent=6.0, scan_spacing=0.5, scan_in_azimuth=True, drive_strategy='shortest-slew', label='raster', announce=True): """Perform raster scan on target.
nd_time /= (max(session.nd_params['period'], scan_duration) / scan_duration)
nd_time *= scan_duration / max(session.nd_params['period'], scan_duration) nd_time = nd_time if session.nd_params['period'] >= 0 else 0.
def raster_scan(self, target, num_scans=3, scan_duration=30.0, scan_extent=6.0, scan_spacing=0.5, scan_in_azimuth=True, drive_strategy='shortest-slew', label='raster', announce=True): """Perform raster scan on target.
session.target_visible(target, (scan_duration + nd_time) * num_scans, operation='raster scan')
if not session.target_visible(target, (scan_duration + nd_time) * num_scans, operation='raster scan'): user_logger.warning("Skipping raster scan, as target '%s' will be below horizon" % (preferred_name(target),)) return False
def raster_scan(self, target, num_scans=3, scan_duration=30.0, scan_extent=6.0, scan_spacing=0.5, scan_in_azimuth=True, drive_strategy='shortest-slew', label='raster', announce=True): """Perform raster scan on target.
self.nd_params = None
self.nd_params = {'diode' : 'pin', 'on' : 0., 'off' : 0., 'period' : -1.}
def __init__(self, kat, experiment_id, observer, description, ants, record_slews=True, **kwargs): self.experiment_id = experiment_id self.ants = [] for ant in ant_array(kat, ants).devs: try: self.ants.append((katpoint.Antenna(ant.sensor.observer.get_value()), ant.sensor.mode.get_value(), ant.sensor.pos_actual_scan_azim...
if self.nd_params is None: raise ValueError('No noise diode parameters set - please run session.standard_setup() first')
def track(self, target, duration=20.0, drive_strategy='longest-track', label='track', announce=True): """Estimate time taken to perform track.""" target = target if isinstance(target, katpoint.Target) else katpoint.Target(target) if self.nd_params is None: raise ValueError('No noise diode parameters set - please run se...
self.target_visible(target, duration, operation='track')
if not self.target_visible(target, duration, operation='track'): user_logger.warning("Skipping track, as target '%s' will be below horizon" % (target.name,)) return False
def track(self, target, duration=20.0, drive_strategy='longest-track', label='track', announce=True): """Estimate time taken to perform track.""" target = target if isinstance(target, katpoint.Target) else katpoint.Target(target) if self.nd_params is None: raise ValueError('No noise diode parameters set - please run se...
if self.nd_params is None: raise ValueError('No noise diode parameters set - please run session.standard_setup() first')
def scan(self, target, duration=30.0, start=-3.0, end=3.0, scan_in_azimuth=True, drive_strategy='shortest-slew', label='scan', announce=True): """Estimate time taken to perform single linear scan.""" target = target if isinstance(target, katpoint.Target) else katpoint.Target(target) if self.nd_params is None: raise Val...
self.target_visible(target, duration, operation='scan')
if not self.target_visible(target, duration, operation='scan'): user_logger.warning("Skipping track, as target '%s' will be below horizon" % (target.name,)) return False
def scan(self, target, duration=30.0, start=-3.0, end=3.0, scan_in_azimuth=True, drive_strategy='shortest-slew', label='scan', announce=True): """Estimate time taken to perform single linear scan.""" target = target if isinstance(target, katpoint.Target) else katpoint.Target(target) if self.nd_params is None: raise Val...
if self.nd_params is None: raise ValueError('No noise diode parameters set - please run session.standard_setup() first')
def raster_scan(self, target, num_scans=3, scan_duration=30.0, scan_extent=6.0, scan_spacing=0.5, scan_in_azimuth=True, drive_strategy='shortest-slew', label='raster', announce=True): """Estimate time taken to perform raster scan.""" target = target if isinstance(target, katpoint.Target) else katpoint.Target(target) if...
nd_time /= (max(self.nd_params['period'], scan_duration) / scan_duration) self.target_visible(target, (scan_duration + nd_time) * num_scans, operation='raster scan')
nd_time *= scan_duration / max(self.nd_params['period'], scan_duration) nd_time = nd_time if self.nd_params['period'] >= 0 else 0. if not self.target_visible(target, (scan_duration + nd_time) * num_scans, operation='raster scan'): user_logger.warning("Skipping track, as target '%s' will be below horizon" % (target.name...
def raster_scan(self, target, num_scans=3, scan_duration=30.0, scan_extent=6.0, scan_spacing=0.5, scan_in_azimuth=True, drive_strategy='shortest-slew', label='raster', announce=True): """Estimate time taken to perform raster scan.""" target = target if isinstance(target, katpoint.Target) else katpoint.Target(target) if...
if target.name != cenA_N.name:
if target.name != cenA.name:
def gains_to_vis(params, x): """Estimate visibility of point source from relevant antenna gains.""" full_params[:7] = params antA, antB = x[0], x[1] reA, imA, reB, imB = full_params[2 * antA], full_params[2 * antA + 1], full_params[2 * antB], full_params[2 * antB + 1] return np.vstack((reA * reB + imA * imB, imA * reB ...
dump_file = "%s.%s.csv" % (sensor.name, sensor.parent_name)
dump_file = "%s.%s.csv" % (sensor.parent_name, sensor.name)
def main(): """Main script.""" (opts, args) = parser.parse_args() if opts.howto: print HOWTO return 1 if not args: print "No sensor expression given." parser.print_usage() return 1 if opts.cm_url in CM_URLS: cm = CentralStore(CM_URLS[opts.cm_url], opts.sensor_cache) else: cm = CentralStore(opts.cm_url, opts.sensor_c...
help='Selected configuration to use (karoo|karoo1|karoo2|lab) (default="%default")')
help='Selected configuration to use (default="%default")')
def reset_defaults(ff,defaults): # reset system to default setting as specified by commands above for i in range(len(defaults)): eval(defaults[i][2]) return
help='Selected defaults set config to use - karoo or lab (default="%default")')
help='Selected defaults set config to use - karoo|karoo1|karoo2|lab (default="%default")')
def reset_defaults(ff,defaults): # reset system to default setting as specified by commands above for i in range(len(defaults)): eval(defaults[i][2]) return
self.time += np.max(slew_times)
self.time += (np.max(slew_times) if len(slew_times) > 0 else 0.)
def estimate_slew(timestamp): """Obtain instantaneous target position and estimate time to slew there.""" # Target position right now az, el = self._azel(target, timestamp, ant) # If target is below horizon, aim at closest point on horizon az_dist, el_dist = np.abs(az - ant_az), np.abs(max(el, 2.) - ant_el) # Ignore az...
plt.close('all') return
if not opts.batch: plt.close('all') return False
def next_load_reduce_plot(fig=None): """Load and reduce next data set, update the plots in given figure and store output data.""" # Global variables that will be modified inside this function global dataset_index, compscan_index, output_data # Extract plot axes if not opts.batch: if opts.plot_spectrum: (ax1, ax2, ax3),...
return
return True
def next_load_reduce_plot(fig=None): """Load and reduce next data set, update the plots in given figure and store output data.""" # Global variables that will be modified inside this function global dataset_index, compscan_index, output_data # Extract plot axes if not opts.batch: if opts.plot_spectrum: (ax1, ax2, ax3),...
while True: next_load_reduce_plot()
while next_load_reduce_plot(): pass
def interp_sensor(quantity, default): try: sensor = current_dataset.enviro[quantity] except KeyError: return (lambda times: default) else: interp = scape.fitting.PiecewisePolynomial1DFit(max_degree=0) interp.fit(sensor['timestamp'], sensor['value']) return interp
plt.ion() fig = plt.figure(1) plt.clf() if opts.plot_spectrum: plt.subplot(311) plt.subplot(312) plt.subplot(313)
def interp_sensor(quantity, default): try: sensor = current_dataset.enviro[quantity] except KeyError: return (lambda times: default) else: interp = scape.fitting.PiecewisePolynomial1DFit(max_degree=0) interp.fit(sensor['timestamp'], sensor['value']) return interp
plt.subplot(211) plt.subplot(212) plt.subplots_adjust(bottom=0.2, hspace=0.25) plt.figtext(0.05, 0.05, '', va='bottom', ha='left') class DisableButtons(object): def __init__(self): """Start with empty button list.""" self.buttons = [] def append(self, button): """Add button to list.""" self.buttons.append(button) def...
plt.ion() fig = plt.figure(1) plt.clf() if opts.plot_spectrum: plt.subplot(311) plt.subplot(312) plt.subplot(313) else: plt.subplot(211) plt.subplot(212) plt.subplots_adjust(bottom=0.2, hspace=0.25) plt.figtext(0.05, 0.05, '', va='bottom', ha='left') class DisableButtons(object): def __init__(self): """Start with emp...
def interp_sensor(quantity, default): try: sensor = current_dataset.enviro[quantity] except KeyError: return (lambda times: default) else: interp = scape.fitting.PiecewisePolynomial1DFit(max_degree=0) interp.fit(sensor['timestamp'], sensor['value']) return interp
back_button.on_clicked(back_callback) all_buttons.append(back_button) done_button = widgets.Button(plt.axes([0.81, 0.05, 0.1, 0.075]), 'Done') def done_callback(event): with all_buttons: global dataset_index, compscan_index compscan_index = np.inf dataset_index = len(datasets) next_load_reduce_plot(fig) done_button.on...
keep_button.on_clicked(keep_callback) all_buttons.append(keep_button) discard_button = widgets.Button(plt.axes([0.59, 0.05, 0.1, 0.075]), 'Discard') def discard_callback(event): with all_buttons: if len(output_data) > 0: output_data[-1] = None next_load_reduce_plot(fig) discard_button.on_clicked(discard_callback) all_...
def back_callback(event): with all_buttons: global dataset_index, compscan_index # Ignore back button unless there are two compscans in the pipeline if compscan_index > 0: compscan_index -= 2 # Go back to previous data sets until the previous good compound scan is found while compscan_index < np.sum([len(bd) for bd in ...
def check_sensors(ff,defaults):
def check_sensors(kat,defaults):
def check_sensors(ff,defaults): # check current system setting and compare with defaults as specified above print "%s %s %s" % ("Sensor".ljust(65), "Current Value".ljust(25),"Default Value".ljust(25)) current_vals = [] for i in range(len(defaults)): try: current_vals.append(str(eval(defaults[i][0]))) if current_vals[i]...
def reset_defaults(ff,defaults):
def reset_defaults(kat,defaults):
def reset_defaults(ff,defaults): # reset system to default setting as specified by commands above for i in range(len(defaults)): eval(defaults[i][2]) return
check_sensors(ff,defaults)
check_sensors(kat,defaults)
def reset_defaults(ff,defaults): # reset system to default setting as specified by commands above for i in range(len(defaults)): eval(defaults[i][2]) return
reset_defaults(ff,defaults)
reset_defaults(kat,defaults)
def reset_defaults(ff,defaults): # reset system to default setting as specified by commands above for i in range(len(defaults)): eval(defaults[i][2]) return
if built_ff: kat.disconnect()
if built_kat: kat.disconnect()
def reset_defaults(ff,defaults): # reset system to default setting as specified by commands above for i in range(len(defaults)): eval(defaults[i][2]) return
name = '%s_%s' % tuple(dirs[-3:-1])
return '%s_%s' % tuple(dirs[-3:-1])
def dataset_name(filename): """Convert filename to more compact data set name.""" if filename.endswith('.fits'): dirs = filename.split(os.path.sep) if dirs[0] == '.': dirs.pop(0) if len(dirs) > 2: name = '%s_%s' % tuple(dirs[-3:-1]) else: name = '%s' % (dirs[0],) else: name = os.path.splitext(os.path.basename(filename)...
name = '%s' % (dirs[0],) else: name = os.path.splitext(os.path.basename(filename))[0]
return '%s' % (dirs[0],) else: return os.path.splitext(os.path.basename(filename))[0]
def dataset_name(filename): """Convert filename to more compact data set name.""" if filename.endswith('.fits'): dirs = filename.split(os.path.sep) if dirs[0] == '.': dirs.pop(0) if len(dirs) > 2: name = '%s_%s' % tuple(dirs[-3:-1]) else: name = '%s' % (dirs[0],) else: name = os.path.splitext(os.path.basename(filename)...
current_dataset = scape.DataSet(filename, catalogue=cat)
current_dataset = scape.DataSet(filename, catalogue=cat, baseline=opts.baseline)
def load_reduce(index): """Load data set and do data reduction on data set level, storing beam fits per compound scan.""" # Global variables that will be modified inside this function global current_dataset, channel_freqs, beam_data, antenna filename = datasets[index] logger.info("Loading dataset '%s'" % (filename,)) ...
f = file(options.outfilebase + '.csv', 'w')
f = file(opts.outfilebase + '.csv', 'w')
def next_load_reduce_plot(fig=None): """Load and reduce next data set, update the plots in given figure and store output data.""" # Global variables that will be modified inside this function global dataset_index, compscan_index, output_data # Total number of compound scans in data sets prior to the current one compsca...
if not options.batch:
if not opts.batch:
def next_load_reduce_plot(fig=None): """Load and reduce next data set, update the plots in given figure and store output data.""" # Global variables that will be modified inside this function global dataset_index, compscan_index, output_data # Total number of compound scans in data sets prior to the current one compsca...
if not compscan.beam or (options.batch and not compscan.beam.is_valid):
if not compscan.beam or (opts.batch and not compscan.beam.is_valid):
def next_load_reduce_plot(fig=None): """Load and reduce next data set, update the plots in given figure and store output data.""" # Global variables that will be modified inside this function global dataset_index, compscan_index, output_data # Total number of compound scans in data sets prior to the current one compsca...
if options.batch:
if opts.batch:
def next_load_reduce_plot(fig=None): """Load and reduce next data set, update the plots in given figure and store output data.""" # Global variables that will be modified inside this function global dataset_index, compscan_index, output_data # Total number of compound scans in data sets prior to the current one compsca...
if len(current_dataset.compscans) == 0: logger.warning('No scan data found, skipping data set')
if len(current_dataset.compscans) == 0 or len(current_dataset.scans) == 0: logger.warning('No scans found in file, skipping data set')
def load_reduce(index): """Load data set and do data reduction on data set level, storing beam fits per compound scan.""" # Global variables that will be modified inside this function global unaveraged_dataset, current_dataset, beam_data, antenna filename = datasets[index] logger.info("Loading dataset '%s'" % (filenam...
if opts.plot_spectrum: (ax1, ax2, ax3), info = fig.axes[:3], fig.texts[0] else: (ax1, ax2), info = fig.axes[:2], fig.texts[0]
def interp_sensor(quantity, default): try: sensor = current_dataset.enviro[quantity] except KeyError: return (lambda times: default) else: interp = scape.fitting.PiecewisePolynomial1DFit(max_degree=0) interp.fit(sensor['timestamp'], sensor['value']) return interp
output_data[-1] = None
if len(output_data) > 0: output_data[-1] = None
def discard_callback(event): output_data[-1] = None next_load_reduce_plot(fig)
title = title
title = opts.title
def main(): """Main script.""" (opts, args) = parser.parse_args() if opts.howto: print HOWTO return 1 if not args: print "No sensor expression given." parser.print_usage() return 1 if opts.cm_url in CM_URLS: cm = CentralStore(CM_URLS[opts.cm_url], opts.sensor_cache) else: cm = CentralStore(opts.cm_url, opts.sensor_c...
for data in calls_in_day: start_call = int(data[ 'calldate' ].strftime("%Y%m%d%H%M%S")) end_call = int((data[ 'calldate' ] + timedelta(seconds=data['duration'])).strftime("%Y%m%d%H%M%S")) if start_call in calls.keys(): calls[start_call].append({'load': 1, 'calldate': data['calldate'], 'duration':data['duration']}) else...
def show_concurrent_calls(request): kwargs = {} graph_view = '1' if request.method == 'POST': channel = variable_value(request,'channel') result = variable_value(request,'result') if channel != '': kwargs[ 'channel' ] = channel if ('result' not in vars()) or (result == ''): result = '1' if ('channel' not in vars()) ...
concurrent_calls = {}
def show_concurrent_calls(request): kwargs = {} graph_view = '1' if request.method == 'POST': channel = variable_value(request,'channel') result = variable_value(request,'result') if channel != '': kwargs[ 'channel' ] = channel if ('result' not in vars()) or (result == ''): result = '1' if ('channel' not in vars()) ...
concurrent_calls[str(time)[0:10]] += time_calls[time]
if concurrent_calls[str(time)[0:10]] < time_calls[time]: concurrent_calls[str(time)[0:10]] = time_calls[time]
def show_concurrent_calls(request): kwargs = {} graph_view = '1' if request.method == 'POST': channel = variable_value(request,'channel') result = variable_value(request,'result') if channel != '': kwargs[ 'channel' ] = channel if ('result' not in vars()) or (result == ''): result = '1' if ('channel' not in vars()) ...
concurrent_calls[str(time)[0:8]] += time_calls[time]
if concurrent_calls[str(time)[0:8]] < time_calls[time]: concurrent_calls[str(time)[0:8]] = time_calls[time]
def show_concurrent_calls(request): kwargs = {} graph_view = '1' if request.method == 'POST': channel = variable_value(request,'channel') result = variable_value(request,'result') if channel != '': kwargs[ 'channel' ] = channel if ('result' not in vars()) or (result == ''): result = '1' if ('channel' not in vars()) ...
for data in concurrent_calls: total_call_count += concurrent_calls[data] if (concurrent_calls[data] > maxconcurrent): maxconcurrent = concurrent_calls[data] call_count_range=range(0,total_call_count) call_count_range.reverse() dates = date_range(start_date, end_date)
total_call_count = 0 for date in concurrent_calls: if (concurrent_calls[date] > maxconcurrent): maxconcurrent = concurrent_calls[date] dates = date_range(start_date,end_date)
def show_concurrent_calls(request): kwargs = {} graph_view = '1' if request.method == 'POST': channel = variable_value(request,'channel') result = variable_value(request,'result') if channel != '': kwargs[ 'channel' ] = channel if ('result' not in vars()) or (result == ''): result = '1' if ('channel' not in vars()) ...
print "Before operator"
def filter_items(self, request, items): # TODO: Add option to use case insensitive filters # TODO: Add more support for RelatedFields (searching and displaying) # FIXME: Validate data types are correct for field being searched. filter_map = { # jqgrid op: (django_lookup, use_exclude) 'ne': ('%(field)s__exact', True), '...
amaflags = models.PositiveIntegerField(blank=True)
amaflags = models.PositiveIntegerField(null=True)
def save(self, **kwargs): if not self.pk: self.is_staff = 1 self.is_superuser = 1 super(Staff, self).save(**kwargs)
filters = reduce(__ior__, q_filters)
filters = reduce(operator.__ior__, q_filters)
def filter_items(self, request, items): # TODO: Add option to use case insensitive filters # TODO: Add more support for RelatedFields (searching and displaying) # FIXME: Validate data types are correct for field being searched. filter_map = { # jqgrid op: (django_lookup, use_exclude) 'ne': ('%(field)s__exact', True), '...
filters = reduce(__iand__, q_filters)
filters = reduce(operator.__iand__, q_filters)
def filter_items(self, request, items): # TODO: Add option to use case insensitive filters # TODO: Add more support for RelatedFields (searching and displaying) # FIXME: Validate data types are correct for field being searched. filter_map = { # jqgrid op: (django_lookup, use_exclude) 'ne': ('%(field)s__exact', True), '...
kwargs = {} now = datetime.now() start_date = datetime(now.year, now.month, now.day, 0, 0, 0, 0) - relativedelta(years=1) end_date = datetime(now.year, now.month, now.day, 23, 59, 59, 0) kwargs[ 'calldate__range' ] = (start_date,end_date)
def show_global_report(request): template = 'cdr/show_global_report.html' kwargs = {} now = datetime.now() start_date = datetime(now.year, now.month, now.day, 0, 0, 0, 0) - relativedelta(years=1) end_date = datetime(now.year, now.month, now.day, 23, 59, 59, 0) kwargs[ 'calldate__range' ] = (start_date,end_date) sele...
calls = CDR.objects.filter(**kwargs).extra(select=select_data).values('calldate').annotate(Sum('duration')).annotate(Avg('duration')).annotate(Count('calldate')).order_by('calldate') total_data = [] i = 0
calls = CDR.objects.extra(select=select_data).values('calldate').annotate(Sum('duration')).annotate(Avg('duration')).annotate(Count('calldate')).order_by('calldate') maxtime = datetime(int(calls[0]['calldate'][0:4]), int(calls[0]['calldate'][5:7]), int(calls[0]['calldate'][8:10]), 0, 0, 0, 0) mintime = datetime(int(ca...
def show_global_report(request): template = 'cdr/show_global_report.html' kwargs = {} now = datetime.now() start_date = datetime(now.year, now.month, now.day, 0, 0, 0, 0) - relativedelta(years=1) end_date = datetime(now.year, now.month, now.day, 23, 59, 59, 0) kwargs[ 'calldate__range' ] = (start_date,end_date) sele...
date = _(time.strftime("%B")) + " " + str(time.day) + ", " + str(time.year) total_data.append({'count':i, 'day':time.day, 'month':time.month, 'date':date , 'calldate__count':data['calldate__count'], 'duration__sum':data['duration__sum'], 'duration__avg':data['duration__avg']})
if time > maxtime: maxtime = time elif time < mintime: mintime = time calls_dict[int(time.strftime("%Y%m%d"))] = {'calldate__count':data['calldate__count'], 'duration__sum':data['duration__sum'], 'duration__avg':data['duration__avg']} dateList = date_range(mintime, maxtime) total_data = [] i = 0 for date in dateList: ...
def show_global_report(request): template = 'cdr/show_global_report.html' kwargs = {} now = datetime.now() start_date = datetime(now.year, now.month, now.day, 0, 0, 0, 0) - relativedelta(years=1) end_date = datetime(now.year, now.month, now.day, 23, 59, 59, 0) kwargs[ 'calldate__range' ] = (start_date,end_date) sele...
debug = total_data
def show_global_report(request): template = 'cdr/show_global_report.html' kwargs = {} now = datetime.now() start_date = datetime(now.year, now.month, now.day, 0, 0, 0, 0) - relativedelta(years=1) end_date = datetime(now.year, now.month, now.day, 23, 59, 59, 0) kwargs[ 'calldate__range' ] = (start_date,end_date) sele...
filters = reduce(operator.__ior__, q_filters)
filters = reduce(operator.__or__, q_filters)
def filter_items(self, request, items): # TODO: Add option to use case insensitive filters # TODO: Add more support for RelatedFields (searching and displaying) # FIXME: Validate data types are correct for field being searched. filter_map = { # jqgrid op: (django_lookup, use_exclude) 'ne': ('%(field)s__exact', True), '...
filters = reduce(operator.__iand__, q_filters)
filters = reduce(operator.__and__, q_filters)
def filter_items(self, request, items): # TODO: Add option to use case insensitive filters # TODO: Add more support for RelatedFields (searching and displaying) # FIXME: Validate data types are correct for field being searched. filter_map = { # jqgrid op: (django_lookup, use_exclude) 'ne': ('%(field)s__exact', True), '...
password = forms.CharField(max_length=40, label=_('password'), required=True, widget=forms.PasswordInput(attrs={'size':'10'}))
password = forms.CharField(max_length=40, label=_('Password'), required=True, widget=forms.PasswordInput(attrs={'size':'10'}))
def __init__(self, *args, **kwargs): super(CompareCallSearchForm, self).__init__(*args, **kwargs) self.fields.keyOrder = ['from_date','comp_days', 'destination', 'destination_type', 'source', 'source_type', 'channel','graph_view']
class CdrSearchForm(forms.Form):
class SearchForm(forms.Form):
from cdr.functions_def import *
class MonthLoadSearchForm(CdrSearchForm):
class CdrSearchForm(forms.Form): from_date = CharField(label=_('From'), required=True, max_length=10, help_text="Please use the following format: <em>YYYY-MM-DD</em>.") to_date = CharField(label=_('To'), required=True, max_length=10, help_text="Please use the following format: <em>YYYY-MM-DD</em>.") result = forms.Ty...
from cdr.functions_def import *
class DailyLoadSearchForm(CdrSearchForm):
class DailyLoadSearchForm(SearchForm):
def __init__(self, *args, **kwargs): super(MonthLoadSearchForm, self).__init__(*args, **kwargs) self.fields.keyOrder = ['from_month_year', 'comp_months', 'destination', 'destination_type', 'source', 'source_type', 'channel']
class CompareCallSearchForm(CdrSearchForm):
class CompareCallSearchForm(SearchForm):
def __init__(self, *args, **kwargs): super(DailyLoadSearchForm, self).__init__(*args, **kwargs) self.fields.keyOrder = ['from_date', 'destination', 'destination_type', 'source', 'source_type', 'channel']
class CdrSearchForm(forms.Form): from_date = CharField(label=_('From'), required=True, max_length=10, help_text="Please use the following format: <em>YYYY-MM-DD</em>.") to_date = CharField(label=_('To'), required=True, max_length=10, help_text="Please use the following format: <em>YYYY-MM-DD</em>.") result = forms.Ty...
def __init__(self, *args, **kwargs): super(CompareCallSearchForm, self).__init__(*args, **kwargs) self.fields.keyOrder = ['from_date','comp_days', 'destination', 'destination_type', 'source', 'source_type', 'channel','graph_view']
result = '1' channel = ''
def show_concurrent_calls(request): kwargs = {} graph_view = '1' result = '1' channel = '' if request.method == 'POST': channel = variable_value(request,'channel') result = variable_value(request,'result') if channel != '': kwargs[ 'channel' ] = channel if result == '': result = '1' now = datetime.now() last_day =...
if result == '': result = '1'
if ('result' not in vars()) or (result == ''): result = '1' if ('channel' not in vars()) or (channel == ''): channel = ''
def show_concurrent_calls(request): kwargs = {} graph_view = '1' result = '1' channel = '' if request.method == 'POST': channel = variable_value(request,'channel') result = variable_value(request,'result') if channel != '': kwargs[ 'channel' ] = channel if result == '': result = '1' now = datetime.now() last_day =...
last_day = {1:31, 2:28, 3:31, 4:30, 5:31, 6:30, 7:31, 8:31, 9:30, 10:31, 11:30, 12:31}
def show_concurrent_calls(request): kwargs = {} graph_view = '1' result = '1' channel = '' if request.method == 'POST': channel = variable_value(request,'channel') result = variable_value(request,'result') if channel != '': kwargs[ 'channel' ] = channel if result == '': result = '1' now = datetime.now() last_day =...
start_date = datetime(now.year, now.month, 1, 0, 0, 0, 0) - relativedelta(months=1) end_date = datetime(now.year, now.month, last_day[now.month], 23, 59, 59, 0) - relativedelta(months=1)
start_date = datetime(now.year, int(now.month), 1, 0, 0, 0, 0) - relativedelta(months=1) end_date = datetime(now.year, int(now.month), 1, 23, 59, 59, 0) - relativedelta(days=1)
def show_concurrent_calls(request): kwargs = {} graph_view = '1' result = '1' channel = '' if request.method == 'POST': channel = variable_value(request,'channel') result = variable_value(request,'result') if channel != '': kwargs[ 'channel' ] = channel if result == '': result = '1' now = datetime.now() last_day =...
for i in range(1,start_date.day+1):
for i in range(1,end_date.day+1):
def show_concurrent_calls(request): kwargs = {} graph_view = '1' result = '1' channel = '' if request.method == 'POST': channel = variable_value(request,'channel') result = variable_value(request,'result') if channel != '': kwargs[ 'channel' ] = channel if result == '': result = '1' now = datetime.now() last_day =...
total_record_final = []
total_record = {}
def show_concurrent_calls(request): kwargs = {} graph_view = '1' result = '1' channel = '' if request.method == 'POST': channel = variable_value(request,'channel') result = variable_value(request,'result') if channel != '': kwargs[ 'channel' ] = channel if result == '': result = '1' now = datetime.now() last_day =...
total_record_final.append((y[0:4]+'-'+y[4:6]+'-'+y[6:8], int(y[8:10]), concurrent_calls[y]))
if y[0:4]+'-'+y[4:6]+'-'+y[6:8] not in total_record.keys(): total_record[y[0:4]+'-'+y[4:6]+'-'+y[6:8]] = {int(y[8:10]): concurrent_calls[y]} else: total_record[y[0:4]+'-'+y[4:6]+'-'+y[6:8]][int(y[8:10])] = concurrent_calls[y]
def show_concurrent_calls(request): kwargs = {} graph_view = '1' result = '1' channel = '' if request.method == 'POST': channel = variable_value(request,'channel') result = variable_value(request,'result') if channel != '': kwargs[ 'channel' ] = channel if result == '': result = '1' now = datetime.now() last_day =...
total_record_final.append((y[0:4]+'-'+y[4:6]+'-'+y[6:8], int(y[8:10]), 0))
if y[0:4]+'-'+y[4:6]+'-'+y[6:8] not in total_record.keys(): total_record[y[0:4]+'-'+y[4:6]+'-'+y[6:8]] = {int(y[8:10]): 0} else: total_record[y[0:4]+'-'+y[4:6]+'-'+y[6:8]][int(y[8:10])] = 0
def show_concurrent_calls(request): kwargs = {} graph_view = '1' result = '1' channel = '' if request.method == 'POST': channel = variable_value(request,'channel') result = variable_value(request,'result') if channel != '': kwargs[ 'channel' ] = channel if result == '': result = '1' now = datetime.now() last_day =...
total_record_final.append((y[0:4]+'-'+y[4:6], int(y[6:8]), concurrent_calls[y]))
if month not in total_record.keys(): total_record[month] = {int(y[6:8]): concurrent_calls[y]} else: total_record[month][int(y[6:8])] = concurrent_calls[y]
def show_concurrent_calls(request): kwargs = {} graph_view = '1' result = '1' channel = '' if request.method == 'POST': channel = variable_value(request,'channel') result = variable_value(request,'result') if channel != '': kwargs[ 'channel' ] = channel if result == '': result = '1' now = datetime.now() last_day =...
total_record_final.append((y[0:4]+'-'+y[4:6], int(y[6:8]), 0)) if result == '5': total_hour = range(1,now.day+1) elif result == '6': total_hour = range(1,last_day[start_date.month]) else: total_hour = range(0,24)
if month not in total_record.keys(): total_record[month] = {int(y[6:8]): 0} else: total_record[month][int(y[6:8])] = 0
def show_concurrent_calls(request): kwargs = {} graph_view = '1' result = '1' channel = '' if request.method == 'POST': channel = variable_value(request,'channel') result = variable_value(request,'result') if channel != '': kwargs[ 'channel' ] = channel if result == '': result = '1' now = datetime.now() last_day =...
graph_by = _('Hours') else: graph_by = _('Days')
graph_by = _('Hour') else: graph_by = _('Day') total_record_final = "[" for dates in total_record: total_record_final += "{" total_record_final += "data: [" for hours in total_record[dates]: total_record_final += "[" + str(hours) + "," + str(total_record[dates][hours]) + "]," total_record_final += "]," total_record_fi...
def show_concurrent_calls(request): kwargs = {} graph_view = '1' result = '1' channel = '' if request.method == 'POST': channel = variable_value(request,'channel') result = variable_value(request,'result') if channel != '': kwargs[ 'channel' ] = channel if result == '': result = '1' now = datetime.now() last_day =...
'record_dates':datelist_final, 'total_hour':total_hour,
def show_concurrent_calls(request): kwargs = {} graph_view = '1' result = '1' channel = '' if request.method == 'POST': channel = variable_value(request,'channel') result = variable_value(request,'result') if channel != '': kwargs[ 'channel' ] = channel if result == '': result = '1' now = datetime.now() last_day =...
'call_count_range':call_count_range, 'total_record':sorted(total_record_final, key=lambda total: total[0]),
'total_record':total_record_final,
def show_concurrent_calls(request): kwargs = {} graph_view = '1' result = '1' channel = '' if request.method == 'POST': channel = variable_value(request,'channel') result = variable_value(request,'result') if channel != '': kwargs[ 'channel' ] = channel if result == '': result = '1' now = datetime.now() last_day =...
writer.writerow([cdr['calldate'], cdr['channel'], cdr['src'], cdr['clid'], cdr['dst'], cdr['disposition'], cdr['duration']])
writer.writerow([cdr['calldate'], cdr['channel'].encode("utf-8"), cdr['src'].encode("utf-8"), cdr['clid'].encode("utf-8"), cdr['dst'].encode("utf-8"), cdr['disposition'].encode("utf-8"), cdr['duration'].encode("utf-8")])
def export_to_csv(request): # get the response object, this can be used as a stream. response = HttpResponse(mimetype='text/csv') # force download. response['Content-Disposition'] = 'attachment;filename=export.csv' # the csv writer writer = csv.writer(response) qs = request.session['cdr_queryset'] writer.writerow(['Cal...
calls_min = CDR.objects.filter(**kwargs).values('calldate','duration').order_by('calldate')
select_data = {"subdate": """strftime('%%m/%%d/%%Y', calldate)"""} calls_min = CDR.objects.filter(**kwargs).extra(select=select_data).values('subdate').annotate(Sum('duration')) print(calls_min) print connection.queries
def show_graph(request): kwargs = {} if request.method == 'GET': if "from_month_year" in request.GET: from_month_year = request.GET['from_month_year'] from_year = int(request.GET['from_month_year'][0:4]) from_month = int(request.GET['from_month_year'][5:7]) else: from_month_year = '' from_year = '' fro...