有代码:
from ftplib import FTP
ftp = FTP('128.171.2.79')
ftp.login() # Anonymous user
如何将服务器响应保存到变量?
示例:
220-FileZilla Server 0.9.55 beta
220 Welcome to server!
530 Login or password incorrect!
214-The following commands are recognized:
ABOR ADAT ALLO APPE AUTH CDUP CLNT CWD
DELE EPRT EPSV FEAT HASH HELP LIST MDTM
MFMT MKD MLSD MLST MODE NLST N...
进入" buffer_out"变量
答案 0 :(得分:1)
ftp.set_debuglevel(2)
。
要获取调试日志打印,请致电putline()
。
要获取客户端覆盖putcmd()
或getline()
发送的每一行(即,创建一个以FTP为基类并实现这些方法的类;在之前或之后调用父方法)。
要获取服务器覆盖getmultiline()
,getresp()
或voidresp()
和if(str_username.equals(globalSharedPrefs.getUserDetail("username").toString()))){
sumbit();
}else {
databaseReference.orderByChild("Username").equalTo(newUsername).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
long userCount = dataSnapshot.getChildrenCount();
if(userCount==0){
sumbit();
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
private void sumbit(){
if(!TextUtils.isEmpty(str_firstName)
&& !TextUtils.isEmpty(str_lastName)
&& !TextUtils.isEmpty(str_username)
&& verify.isEmailValid(str_email)
&& verify.isMobileNoValid(str_mobile)
){
progressDialog.setMessage("Saving Profile ...");
progressDialog.show();
//saving the photo
if(isImageClicked) {
filepath = storageReference.child("profile_photos").child(globalSharedPrefs.getUserDetail("uid").toString());
filepath.putFile(imageUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
//TODO: add picture remote/edit button in the XML
isImageClicked = false;
downloadUri = taskSnapshot.getDownloadUrl();
databaseReference.child("Profile Picture").setValue(downloadUri.toString());
uploadUserInfo();
Toast.makeText(UserProfileActivity.this, "Profile Saved.!", Toast.LENGTH_LONG)
.show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
progressDialog.dismiss();
updateProfileUI();
clickEditProfileButton(false);
Toast.makeText(UserProfileActivity.this, "Update Failed.!", Toast.LENGTH_LONG)
.show();
}
});
}
}
返回的每一行;在代码之前调用父方法。
请参阅ftplib.py的源代码,您可能会发现许多想要覆盖的方法。