Commit 9bbabd32 authored by POTHULA SAI VISHAL's avatar POTHULA SAI VISHAL

first commit

parents
{"url": "http://10.2.64.57:7000", "path": "/home/psn/Project", "password": "@12345678", "username": "nar"}
\ No newline at end of file
import json
with open("details.json") as f:
details=json.load(f)
print(details)
\ No newline at end of file
import sys
import json
import requests
if len(sys.argv)==4:
name=sys.argv[1]
password=sys.argv[2]
path=sys.argv[3]
file=path+"/details.json"
with open(file) as f:
details=json.load(f)
if details["url"]=="none":
print("You need to first set server url")
print("Try executing 'spc set-url'")
else :
ping=details["url"]+"/linux/login"
headers={'content-type':'application/json'}
foo={"username":name,"password":password}
r=requests.post(ping, data=json.dumps(foo),headers=headers)
d=json.loads(r.text)
if d["yes"] == "yes" :
details["username"]=name;
details["password"]=password;
details["path"]=path;
with open(file, 'w') as outfile:
json.dump(details, outfile)
print("login successful!")
else :
print("invalid login credentials")
else :
url=sys.argv[1]
path=sys.argv[2]
file=path+"/details.json"
with open(file) as f:
details=json.load(f)
details["url"]="http://"+url;
with open(file, 'w') as outfile:
json.dump(details, outfile)
print("server ip is set to - ",details["url"])
import sys
import json
file=sys.argv[1]
file=file+"/details.json"
with open(file) as f:
details=json.load(f)
details={"password": "none", "url": "none", "username": "none", "path": "none"}
with open(file,'w') as g:
json.dump(details,g)
\ No newline at end of file
import sys
import json
file=sys.argv[2]+"details.json"
with open(file) as f:
details=json.load(f)
details[dir]=sys.argv[1]
with open(file,'w') as g
json.dump(details,g)
/home/psn/ee101
#!/bin/bash
count=0
total=34
pstr="[=======================================================================]"
while [ $count -lt $total ]; do
sleep 0.5 # this is work
count=$(( $count + 1 ))
pd=$(( $count * 73 / $total ))
printf "\r%3d.%1d%% %.${pd}s" $(( $count * 100 / $total )) $(( ($count * 1000 / $total) % 10 )) $pstr
done
#!/bin/bash
path=$(pwd spc)
if [[ $# -eq 1 ]]; then
if [[ $1 == "login" ]]; then
t="/login.py"
file="$path$t"
echo -n "Enter Username: "
read name
echo -n "Enter Password: "
read pswrd
python3 $file $name $pswrd $path
elif [[ $1 == "sync" ]]; then
t="/observe.txt"
u="/upload.py"
file2="$path$u"
file="$path$t"
dir=$(cat $file)
s=""
for temp in $(find $dir); do
p=$(echo $temp)
m="\n"
s="$s$m$p"
done
python3 $file2 $s $path
elif [[ $1 == "help" ]]; then
echo login, set-url "["server ip"]", observe "["directory to be observed"]", sync, version, server, help.
elif [[ $1 == "logout" ]]; then
t="/logout.py"
file="$path$t"
python3 $file $path
fi
elif [[ $# -eq 2 ]]; then
if [[ $1 == "set-url" ]]; then
t="/login.py"
file="$path$t"
python3 $file $2 $path
elif [[ $1 == "observe" ]]; then
t="/observe.txt"
file="$path$t"
echo "$2" > $file
echo "$2" is under observation.
fi
fi
import sys
with open('test.txt','rb') as f:
det=f.read()
foo={"ans":det}
with open('test2.txt','wb') as g:
g.write(foo["ans"])
\ No newline at end of file
import sys
import requests
import json
import os.path
path=sys.argv[2]
temp=path+"/details.json"
with open(temp) as f:
details=json.load(f)
s=sys.argv[1]
l=s.split("\\n")
l=l[2:]
for file in l:
with open(file,'rb') as g:
content=g.read()
ping=details["url"]+"/upload"
files={"file": (os.path.abspath(file),open(file,'rb')),"det":open("details.json")}
r=requests.post(ping,files=files)
d=json.loads(r.text)
if d["yes"] == "yes":
print("Successfully uploaded ",file)
else :
print("Invalid credentials")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment