Beispiel #1
0
    def setExename(self):
        try:
            cmd = self.entry["command"]
        except KeyError:
            raise Prophet.NotSet("no command entry found")
        self.testGoodness(cmd)
        scmd = cmd.split(" ", 1)
        if len(scmd) >= 2:
            cmd = scmd[0].strip()
            args = scmd[1].strip()
            for x in args.split():
                if fnmatch.fnmatch(x, "*/*/*") and not os.path.exists(x):
                    # An argument specified in the command line looks like a path. If it
                    # doesn't exist, the entire command is likely to be
                    # worthless, so throw it off
                    raise Prophet.NotSet(
                        "nonexistent path %s as command argument")

            self.exeargs = args
        if not runDebian:
            # If we're not running Debian specified command may be located
            # elsewhere therefore we have to scan PATH for it
            cmd = os.path.basename(cmd)
            # List of globs of unwanted commands
            if cmd in ("sh", "bash", "csh", "tcsh", "zsh", "ls", "killall",
                       "echo", "nice", "xmessage", "xlock"):
                # Debian seems to have lots of shell commands. While it would be nice
                # to try to analyze them, this isn't a priority since they're often
                # too Debian-specific.
                raise Prophet.NotSet("%s blacklisted" % cmd)

        self.exename = cmd
Beispiel #2
0
def predict(algorithm, params, data, time):
    alg_name = algorithm.lower()
    if alg_name == 'arima':
        arima_model = arima(params)
        arima_model.fit(data)
        result = arima_model.predict(time)
        return result
    if alg_name == 'Prophet':
        prophet_model = Prophet(params)
        prophet_model.fit(data)
        result = prophet_model.predict(time)
        return result
Beispiel #3
0
    def setTerminal(self):
        try:
            needs = Kw(self.entry["needs"])
            if needs == Kw("X11"):
                self.terminal = False
            elif needs == Kw("text"):
                self.terminal = True
            else:
                raise Prophet.NotSet("unsupported needs entry (%s)" % needs)

        except KeyError:
            super(App, self).setTerminal()
Beispiel #4
0
 def setKeywords(self):
     try:
         sect = self.entry["section"]
     except KeyError:
         sect = ""
     try:
         hint = self.entry["hints"]
     except KeyError:
         hint = ""
     kws = _deb2kws(sect, hint)
     if not len(kws):
         raise Prophet.NotSet("no keywords guessed")
     self.keywords = kws
Beispiel #5
0
	def __init__(self) :
		subs = []
		try :
			prefix = pekwm().prefix
			themeset = os.path.join(prefix, "share/pekwm/scripts/pekwm_themeset.pl")
			if Prophet.isExe(themeset) :
				for dir in (os.path.join(prefix, "share/pekwm/themes"), "~/.pekwm/themes") :
					if os.path.isdir(os.path.expanduser(dir)) :
						subs.append(X(None, "Dynamic %s %s" % (themeset, dir)))
		except Prophet.NotSet :
			pass
		super(ThemesMenu, self).__init__(subs)
		self.align = MenuMaker.Entry.StickBottom
Beispiel #6
0
    def setKeywords(self):
        try:
            cats = self.desktop["Categories"]
            if type(cats) == tuple:
                self.keywords = KwS(*cats)
            else:
                self.keywords = KwS(cats)
        except KeyError:
            if _kws:
                self.keywords = _kws
            else:
                raise Prophet.NotSet("Categories not found")

        if fnmatch.fnmatch(self.exename, "*kcmshell"):
            self.keywords |= KwS(KDE, Kw("X-KDE-settings"))
Beispiel #7
0
    def __init__(self):
        subs = []
        try:
            prefix = pekwm().prefix
            themeset = os.path.join(prefix,
                                    "share/pekwm/scripts/pekwm_themeset.pl")
            if Prophet.isExe(themeset):
                for dir in (os.path.join(prefix, "share/pekwm/themes"),
                            "~/.pekwm/themes"):
                    if os.path.isdir(os.path.expanduser(dir)):
                        subs.append(X(None, "Dynamic %s %s" % (themeset, dir)))

        except Prophet.NotSet:
            pass
        super(ThemesMenu, self).__init__(subs)
        self.align = MenuMaker.Entry.StickBottom
Beispiel #8
0
def train_model_on_country(prophet_df, country="US"):
    # Train model
    m = Prophet(  #daily_seasonality = True,
        #yearly_seasonality = False,
        #weekly_seasonality = True,
        #growth='linear',
        interval_width=0.68  # one sigma
    )
    m.add_country_holidays(country_name=country)

    m.fit(prophet_df)
    return m
Beispiel #9
0
def _deb2kws(sec, hint):
    """Convert Debian style section/hints entries to an equivalent keyword set"""
    kws = []
    for x in sec.split("/"):
        x = Kw(x)
        if x in _rejs:
            raise Prophet.NotSet("section %s rejected" % x)
        try:
            kws += _secs[x]
        except KeyError:
            pass

    for x in hint.split(","):
        x = Kw(x)
        try:
            kws += _hints[x]
        except KeyError:
            pass

    return KwS(*kws)
Beispiel #10
0
    def getPrefixes(self):
        prefixes = super(ZeroG, self).getPrefixes()
        try:
            zerog = open(os.path.expanduser(self.registry), "r")
            pattern = re.compile(
                ".*<product.*name=\"(%s)\".*location=\"(.*)\".*last_modified=\"(.*)\".*>.*"
                % self.magic)
            found = []
            for x in zerog:
                rx = pattern.match(x)
                if rx:
                    found.append((rx.group(3), rx.group(1), rx.group(2)))

            zerog.close()
            found.sort()
            found.reverse()
            prefixes = Prophet.PrefixSet([x[2] for x in found]) + prefixes
        except IOError:
            pass
        return prefixes
Beispiel #11
0
def main(argv):
    inputfile = ''
    outputfile = ''
    try:
        opts, args = getopt.getopt(argv,"i:o:p:",["ifile=","ofile=","protocol="])
    except getopt.GetoptError:
        print('Error')
        sys.exit(2)

    for opt, arg in opts:
        if opt in ("-p", "--protocol"):
                protocol = arg
    if protocol == "Ep":
        ep = Epidemic()
        ep.assign_global_variables(opts, args)
        ep.running()
    elif protocol == "SW":
        sw = SprayandWait()
        sw.assign_global_variables(opts, args)
        sw.running()
    elif protocol == "Pro":
        pro = Prophet()
        pro.assign_global_variables(opts, args)
        pro.running()
    elif protocol == "3R":
        thr = ThreeR()
        thr.assign_global_variables(opts, args)
        thr.running()
    elif protocol =="FGDR":
        fgdr = FGDR()
        fgdr.assign_global_variables(opts, args)
        fgdr.running()
    elif protocol =="FGPro":
        fgdr = FGProphet()
        fgdr.assign_global_variables(opts, args)
        fgdr.running()
	def relevant(self, path) :
		if Prophet.isExe(os.path.join(path, "lazarus")) :
			raise lazarus.StopDescention(path)
Beispiel #13
0
	Prophet.Legacy.setup()
	legacy  = Prophet.Legacy.scan()




if noDebian :
	msg("  skipping Debian")
	debian = []
else :
	debian = Prophet.Debian.scan()




merged = Prophet.merge(legacy + desktop + debian)




msg("* generating")




if not Prophet.skip[Prophet.App.Console] :
	try :
		MenuMaker.terminal = term()
	except Prophet.NotSet :
		fatal("specified terminal emulator couldn't be found; try another one")
	except NameError :
Beispiel #14
0
	def relevant(self, path) :
		if Prophet.isExe(os.path.join(path, "opera")) :
			raise opera.StopDescention(path)
Beispiel #15
0
if noLegacy:
    msg("  skipping legacy")
    legacy = []
else:
    import Prophet.Legacy
    Prophet.Legacy.setup()
    legacy = Prophet.Legacy.scan()

if noDebian:
    msg("  skipping Debian")
    debian = []
else:
    import Prophet.Debian
    debian = Prophet.Debian.scan()

merged = Prophet.merge(legacy + desktop + debian)

msg("* generating")

if not Prophet.skip[Prophet.App.Console]:
    try:
        MenuMaker.terminal = term()
    except Prophet.NotSet:
        fatal("specified terminal emulator couldn't be found; try another one")
    except NameError:
        warn("  no terminal emulator specified; will use the default")
        found = False
        for tcls, tname in terms:
            try:
                MenuMaker.terminal = tcls()
                found = True
Beispiel #16
0
 def relevant(self, path):
     if Prophet.isExe(os.path.join(path, "opera")):
         raise opera.StopDescention(path)
Beispiel #17
0
 def relevant(self, path):
     if Prophet.isExe(os.path.join(path, "eclipse")):
         raise eclipse.StopDescention(path)
Beispiel #18
0
 def relevant(self, path):
     if Prophet.isExe(os.path.join(path, "bin/netbeans")):
         raise netbeans.StopDescention(path)
	def relevant(self, path) :
		if Prophet.isExe(os.path.join(path, "bin/netbeans")) :
			raise netbeans.StopDescention(path)
Beispiel #20
0
 def getPrefixes(self):
     return Prophet.PrefixSet(
         os.path.join(wmaker().prefix,
                      "lib/GNUstep/Applications/WPrefs.app")) + super(
                          WPrefs, self).getPrefixes()
	def relevant(self, path) :
		if Prophet.isExe(os.path.join(path, "eclipse")) :
			raise eclipse.StopDescention(path)
Beispiel #22
0
 def relevant(self, path):
     if Prophet.isExe(os.path.join(path, "lazarus")):
         raise lazarus.StopDescention(path)