Esempio n. 1
0
File: main.go Progetto: shaalx/push
func main() {
	screen()
	return
	listener, err := net.ListenTCP("tcp", &net.TCPAddr{Port: 8080})
	if exc.Checkerr(err) {
		return
	}
	go func() {
		for {

			time.Sleep(3e9)
			for k, v := range Conn_Keeper.Conns {
				fmt.Printf("send msg to %s\n", k)
				_, err = v.Write([]byte("hello,push msg."))
				fmt.Println(err)
				if exc.Checkerr(err) {
					Conn_Keeper.Delete(v.RemoteAddr().String())
				}
			}
		}
	}()
	for {
		conn, err := listener.AcceptTCP()
		if exc.Checkerr(err) {
			continue
		}
		Conn_Keeper.Set(conn.RemoteAddr().String(), conn)
	}
}
Esempio n. 2
0
func main() {
	wd, err := os.Getwd()
	if exc.Checkerr(err) {
		os.Exit(-1)
	}
	go searchDir(wd)
	time.Sleep(10e8)
	logging()
}
Esempio n. 3
0
func (c *CodeURI) Unzip() bool {
	unzip_command := fmt.Sprintf("unzip %s.zip", c.Branch)
	cmd := exc.NewCMD(unzip_command)
	_, err := cmd.Debug().Do()
	if !exc.Checkerr(err) {
		rename_command := fmt.Sprintf("mv %s %s", c.UnzipName(), c.Repo)
		_, err = os.Stat(c.Repo)
		if nil == err {
			err = os.RemoveAll(c.Repo)
			checkerr(err)
		}
		_, renamed := cmd.Reset(rename_command).Do()
		if !exc.Checkerr(renamed) {
			zipfile := fmt.Sprintf("%s.zip", c.Branch)
			removed := os.Remove(zipfile)
			if !checkerr(removed) {
				return false
			}
			return true
		}
	}
	return false
}
Esempio n. 4
0
func searchDir(dir string) {
	file, err := os.Open(dir)
	if exc.Checkerr(err) {
		return
	}
	subdirs, err := file.Readdir(-1)
	if exc.Checkerr(err) {
		return
	}
	for _, it := range subdirs {
		if strings.EqualFold(it.Name(), ".git") {
			continue
		}
		if it.IsDir() {
			/*go*/ searchDir(filepath.Join(dir, it.Name()))
		}
		if strings.HasSuffix(it.Name(), ".md") {
			absName := filepath.Join(dir, it.Name())
			cmd := fmt.Sprintf("md -r -f %s", absName)
			b, err := command.Cd(dir).Reset(cmd).Do()

			subName := absName[len(wd):]
			target := filepath.Join(wd, "MDFs", subName[:len(subName)-3])
			target_dir := filepath.Dir(target)
			cmd = fmt.Sprintf("mkdir -p %s", target_dir)
			command.Reset(cmd).Execute()
			cmd = fmt.Sprintf("mv -u %s.html %s.html", absName, target)
			command.Reset(cmd).Execute()
			if nil != err {
				installInfo <- NewInfo(dir, false, goutils.ToString(b))
			} else {
				installInfo <- NewInfo(dir, true, "")
			}
			command.Cd("..")
		}
	}
}
Esempio n. 5
0
func (c *CodeURI) curl() bool {
	uri := c.URI()
	curl_command := fmt.Sprintf("curl %s\n", uri)
	b, err := exc.NewCMD(curl_command).Do()
	if !exc.Checkerr(err) {
		f, err := os.OpenFile(fmt.Sprintf("%s.zip", c.Branch), os.O_WRONLY|os.O_CREATE, 0644)
		defer f.Close()
		if checkerr(err) {
			return false
		}
		src := bytes.NewReader(b)
		_, err = io.Copy(f, src)
		if !checkerr(err) {
			return true
		}
	}
	return false
}